Cheaper bulk operations
There are times when you need to perform more than one request on Elasticsearch. For this, Elasticsearch offers a bulk API with the _bulk
endpoint that allows you to perform bulk operations in a single request, be it indexing, updating, or deleting more than one document, getting more than one document using more than one document ID, or executing more than one query in a single request. The best part is that bulk operations can be executed on more than one index
and doc
type in a single request. The Elasticsearch Java client also offers a BulkProcessor
class, which will be covered in a later section of this chapter. For now, let's explore the bulk requests.
Note
The Python client provides a helper module to create bulk operations. You need to import this module from elasticsearch.helpers
import bulk
.
Bulk create
Bulk create
allows to create documents only if they do not already exist in the index. It expects _source
for each document to be separated with new lines.
Python...