william007
william007

Reputation: 18545

Grouping elastic seach put commands

Is there a way to group 3 commands below into 1 command?

PUT /vehicles/_doc/123
{
  "make" : "Honda civic", 
  "color" : "Blue", 
  "from": "Japan",
  "size": "Big",
  "HP" : 250, 
  "milage" : 24000, 
  "price": 19300.97
}

PUT /vehicles/_doc/456
{
  "make" : "honda civic", 
  "color" : "Blue", 
  "from": "Singapore",
  "size": "Big",
  "HP" : 250, 
  "milage" : 24000, 
  "price": 19300.97
}

PUT /vehicles/_doc/789
{
  "make" : "Toyota", 
  "color" : "Blue", 
  "from": "Japan",
  "size": "Big",
  "HP" : 250, 
  "milage" : 24000, 
  "price": 19300.97
}

Upvotes: 0

Views: 38

Answers (2)

hkulekci
hkulekci

Reputation: 1942

You can use _bulk API as @Amit said. Here is a sample also:

POST vehicles/_bulk
{"index": {"_id": "123"}}
{"make" : "Honda civic", "color" : "Blue", "from": "Japan",  "size": "Big",  "HP" : 250, "milage" : 24000, "price": 19300.97}
{"index": {"_id": "456"}}
{"make" : "honda civic", "color" : "Blue", "from": "Singapore","size": "Big","HP" : 250, "milage" : 24000, "price": 19300.97}
{"index": {"_id": "789"}}
{"make" : "Toyota", "color" : "Blue", "from": "Japan","size": "Big","HP" : 250, "milage" : 24000, "price": 19300.97}

Upvotes: 1

Amit
Amit

Reputation: 32376

Definitely you can use the Elasticsearch bulk API for indexing multiple index request into one request.

You can also specify the id of them, as you are using your own ids(not the Elasticsearch generated one) for your documents.

Upvotes: 1

Related Questions