Updating a document

Documents stored in ElasticSearch can be updated at any time throughout their lives. There are two available solutions to perform this operation in ElasticSearch, namely by adding the new document, or by using the update call.

The update call works in two ways:

  1. By providing a script (based on supported ElasticSearch scripting languages) which contains the code that must be executed to update the record
  2. By providing a document that must be merged with the original one

The main advantage of an update versus an index is the reduction in networking.

Getting ready

You will need a working ElasticSearch cluster and the indexed document of the Indexing a document recipe in this chapter. To use the dynamic scripting languages, the dynamic ...

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.