ElasticSearch allows updating a document in-place.
Updating a document via scripting reduces networking traffic (otherwise, you need to fetch the document, change the field, and send it back) and allows improving performance when you need to process a huge amount of documents.
You need a working ElasticSearch cluster and an index populated with the script used for facet processing, available in the online code.
For updating using a scripting, we will perform the following steps:
We'll write an update action that adds a tag value to a list of tags available in the source of a document. It should look as shown in the following code:
curl -XPOST 'http://127.0.0.1:9200/test-index/test-type/9/_update?&pretty=true' -d '{ "script" : "ctx._source.tag += tag", "params" : { "tag" : "cool" } }'
If everything is correct, the result returned by ElasticSearch should be:
{ "ok" : true, "_index" : "test-index", "_type" : "test-type...