When we are inserting/deleting/updating a large number of documents, the HTTP overhead is significant to speed up the process, which ElasticSearch allows executing bulk of calls.
As we are changing the state of the data the HTTP method is POST and the following is the REST URL:
http://<server>/<index_name/_bulk
For executing a bulk action, we need to perform the following steps:
We need to collect the create/index/delete/update commands in a structure made up of bulk JSON lines, composed by a line of action with metadata and another line optional of data related to the action. Every line must be ended with a newline character "
\n
".A bulk datafile should be as follows:
{ "index":{ "_index":"myindex", "_type":"order", "_id":"1" } } { "field1" : "value1", "field2" : "value2" } { "delete":{ "_index":"myindex", "_type":"order", "_id":"2" } } { "create":{ "_index":"myindex", "_type...