How do I update multiple items in ElasticSearch? How do I update multiple items in ElasticSearch? elasticsearch elasticsearch

How do I update multiple items in ElasticSearch?


Try this using _bulk:

http://127.0.0.1:9200/myindex/type/_bulk{"update": {    "_index": "myindex",    "_type": "type",    "_id": "myid"}}{"doc": {    "field": "new value"}}{"update": {    "_index": "myindex",    "_type": "type",    "_id": "id"}}{"doc": {    "field": "new value"}}


All updates in ElasticSearch are done by finding the record, deleting the old version and adding the new version. You can save a little bit on moving records all the way to the client by using Update API. It would still require finding the record though.

What you, probably, want is Update by query.


This works for me.

input_list.dat:

{ "index" : { "_index": "my_index", "_type": "my_type", "_id": "existing-value" } }{ "Field_to_update": "New_Value" }{ "index" : { "_index": "my_index", "_type": "my_type", "_id": "existing_value" } }{ "Field_to_update": "New_Value" }

Command:

curl -k -XPOST 'https://my_host:9200/my_url/_bulk' --data-binary "@input_list.dat"; echo