Updating by query
In the previous chapter, we saw how to update a document (Chapter 4, Basic Operations, Â Update a document recipe).
The update_by_query
API call allows the user to execute the update on all the documents that match a query. It is very useful if you need to do the following:
Reindex a subset of your records that match a query. It's common if you change your document mapping and need the documents to be reprocessed.
Update values of your records the match a query.
This functionality is provided by an additional module called reindex that is installed by default.
Getting ready
You will need an up-and-running Elasticsearch installation as used in the Downloading and installing Elasticsearch recipe in Chapter 2, Downloading and Setup.
To execute curl
via a command line, you need to install curl
for your operating system.
To correctly execute the following commands, you will need an index populated with the chapter_05/populate_query.sh
script available in the online code.