Managing bulk actions
Executing automatic operations on items via a single call is often 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 4, Basic Operations.
Getting ready
You need an up-and-running Elasticsearch installation as we described in the Downloading and installing Elasticsearch recipe in Chapter 2, Downloading and Setup.
A Maven tool, or an IDE that natively supports it for Java programming such as Eclipse or IntelliJ IDEA, must be installed.
The code of this recipe is in the chapter_14/nativeclient
 directory and the referred class is the BulkOperations
.
How to do it...
For managing a bulk action, we will perform these steps:
We'll need to import the required classes to execute bulks via the native
client
:import org.elasticsearch.action.bulk.BulkRequestBuilder; ...