Reputation: 987
I have a scenario where we have an array field on documents and we're trying to update a key/value in that array on each document, so for instance a doc would look like:
_source:{
"type": 1,
"items": [
{"item1": "value1"},
{"item2": "value2"}
]
}
We're trying to efficiently update "value1" for instance on every doc of "type": 1. We'd like to avoid conflicts and we're hoping we can do this all by using a scrip, preferably in python, but I can't find any examples of how to update fields in python, let alone across multiple documents.
So, is it possible to do this with a script and if so, does anyone have a good example?
Thanks
Upvotes: 1
Views: 1196
Reputation: 26
I know this is a little late, but I came across this in a search so I figured I would answer for anyone else who comes by. You can definitely do this utilizing the elasticsearch python library.
You can find all of the info and examples you need via the Elasticsearch RTD.
More specifically, I would look into the "ingest" operations as you can update specific pieces of documents within an index using elasticsearch.
So your script should do a few things:
Upvotes: 1