elasticsearch 如果已经存在具有相同_id的索引文档,则在批量POST期间引发错误?

ht4b089n  于 7个月前  发布在  ElasticSearch
关注(0)|答案(1)|浏览(96)

我可以看到,对于非批量PUT操作,这个功能是存在的,对于_id字段,使用“op_type”as explained in the API
我尝试了这个URL:
https://localhost:9200/my_index/_bulk/?op_type=create
并且还
https://localhost:9200/my_index/_bulk?op_type=create
两者都失败了:

"error": {
    "reason": "request [/my_index/_bulk/] contains unrecognized parameter: [op_type]",

字符串
有没有什么方法可以做到这一点呢?请求体是批量字符串本身,方法是POST。

bcs8qyzn

bcs8qyzn1#

您只需要在_bulk中使用create而不是index

DELETE test

POST test/_bulk?refresh
{"create": {"_id": "foo"}}
{"test": 1}
{"create": {"_id": "foo"}}
{"test": 2}

POST test/_search
{
  "query": {
    "match_all": {}
  }
}

字符串

相关问题