Managing bulk actions
Executing automatic operations on items via a single call will often be the cause of a bottleneck if you need to index or delete thousands/millions of records. The best practice, in this case, is to execute a bulk action.
We have discussed bulk actions via the REST API in the Speeding up atomic operations (bulk) recipe in Chapter 3, Basic Operations.
Getting ready
You need an up-and-running Elasticsearch installation, which you can get using the Downloading and installing Elasticsearch recipe in Chapter 1, Getting Started.
A Maven tool or an IDE that natively supports it for Java programming, such as Visual Studio Code, Eclipse, or IntelliJ IDEA, must be installed.
The code of this recipe is in the ch13/elasticsearch-java-client
directory and the referred class is BulkOperations
.
How to do it...
To manage a bulk action, we will perform these steps:
- We'll need to import the required classes to execute bulk actions via the high...