Elasticsearch: update existing document by inserting elements to its array fields Elasticsearch: update existing document by inserting elements to its array fields elasticsearch elasticsearch

Elasticsearch: update existing document by inserting elements to its array fields


You dont need to use bulk API for this. You can use an upsert request. Upsert request can ALSO be embedded in the bulk request.

curl -XPOST 'localhost:9200/test/type1/1/_update' -d '{  "script": "if (ctx._source.tags.contains(\"tags\")) {ctx._source.tags += tag;} else {ctx._source.tags = [tag]}",  "params": {    "tag": "newTag"  },  "upsert": {    "title": "My first blog entry",    "text": "Starting to get the hang of this...",    "tags": [      "newTag"    ],    "views": 0  }}'