The bulk processing functionality provided by Elasticsearch is implemented by using the _bulk API. This feature is important because it provides a very efficient mechanism to complete multiple operations as quickly as possible, while using as few network round trips as possible.
1, batch index, that is, batch add documents
Two documents (ID 1-john doe and ID 2-jane Doe) were indexed in a bulk operation at a reduced time:
Curl-xpost'Localhost:9200/customer/external/_bulk?pretty'-D'{"Index":{"_id":"1"}} {"name":"John Doe" } {"Index":{"_id":"2"}} {"name":"Jane Doe" } '
2, the following example in a bulk operation, first update the first document (ID 1), and then delete the second document (ID 2):
Curl-xpost'Localhost:9200/customer/external/_bulk?pretty'-D'{"Update":{"_id":"1"}} {"Doc": {"name":"John Doe becomes Jane Doe" } } {"Delete":{"_id":"2"}} '
Note the delete action above, because the delete action only needs to be deleted document ID, so there is no corresponding source document.
The bulk API performs these actions sequentially. If one of the actions fails for some reason, it will continue to handle the actions behind it. When the bulk API returns, it will provide the status of each action (in the same order), so you can see whether an action is successful or not.
Elasticsearch Batch Manipulation--bulk API