Not Clear How To Upsert Elasticsearch Using Python Elasticsearch
Look here for a similar example: https://stackoverflow.com/a/33247409/1575066 from elasticsearch import Elasticsearch es = Elasticsearch('localhost:9200') es.update(index='test',do
Solution 1:
You can put your script
inside the body
parameter.
from elasticsearch import Elasticsearch
es = Elasticsearch()
es.update(
index="test",
doc_type="test1",
id="1",
body={"script": "ctx._source.tags+=new_tag",
"params": {
"new_tag" : "search"
}
}
)
More on update api
Here tags is an array and I am appending search to it. Also you need to enable scripting for this or you can put script in a file and put that file inside config/scripts
folder. Syntax might be different depending on ES version. Let me know if it does not work.
Post a Comment for "Not Clear How To Upsert Elasticsearch Using Python Elasticsearch"