Updating a document using scripts

ElasticSearch allows you to update a document in its place.

Updating a document via scripting reduces the network traffic (otherwise, you would need to fetch the document, change the field, and send it back) and improves performance when you need to process huge amounts of documents.

Getting ready

You will need a working ElasticSearch cluster and an index populated with the script used in Chapter 6, Aggregations, which is available at https://github.com/aparo/elasticsearch-cookbook-second-edition.

How to do it...

In order to update a document using scripting, perform the following steps:

  1. Write an update action that adds a tag value to a list of tags available in the source of a document. This is how the code should ...

Get ElasticSearch Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.