Batch indexing to speed up your indexing process
In the first chapter, we've seen how to index a particular document into ElasticSearch. Now it's time to tell how to index many documents in a more convenient and efficient way than doing it one by one.
Some of the information in this chapter should not be new to us. We've already used it when preparing test data in the previous parts of this book, but now we'll summarize this knowledge.
How to prepare data
ElasticSearch allows us to merge many requests into one packet and send this in one request. In this way, we can mix three operations: adding or replacing existing documents in the index (index), removing documents from the index (delete), or adding new documents to the index when there is not another definition of the document in the index (create). The format of the request was chosen for processing efficiency and assumes that every line of the request contains a JSON object with the operation description followed by the second line with...