how to insert multiple records in one query?

elasticsearch

Solution

You need to use elasticsearch Bulk API. It allows you to insert multiple items with one request. Requests are POSTed to special endpoint `/_bulk` and look like this:

{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{ "field1" : "value1" }
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
{ "field1" : "value2" }
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "3" } }
{ "field1" : "value3" }

Problem

for example : ``` curl -XPUT 'http://localhost:9200/test/users/2' -d '{ "firstname" : "test" }' ``` insert only one record. How to insert multiple records in one query?

Original source