分组ElasticSearch放置命令

pbwdgjma  于 2022-12-11  发布在  ElasticSearch
关注(0)|答案(2)|浏览(93)

是否有办法将下面的3个命令组合成1个命令?

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
}
gcuhipw9

gcuhipw91#

您可以使用_bulk API,如@Amit所言。以下也是一个示例:

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}
ecbunoof

ecbunoof2#

当然,您可以使用Elasticsearch bulk API将多个索引请求索引到一个请求中。
您也可以指定它们的id,因为您正在使用您自己的id(而不是Elasticsearch生成的id)来处理您的文档。

相关问题