ElasticSearch通过查询删除记录时出错

时间:2017-10-23 21:02:56

标签: elasticsearch kibana

我试图通过delete_by_query删除ES中的大量文档。 但我看到以下错误。

查询

POST indexName/typeName/_delete_by_query
{ 
  "size": 100000,
  "query": {
    "bool": {
      "must": [
        { 
          "range": {
            "CREATED_TIME": {
              "gte": 0,
              "lte": 1507316563000
            }
          }
        }
      ]
    }
  } 
}

结果

{
  "took": 50489,
  "timed_out": false,
  "total": 100000,
  "deleted": 0,
  "batches": 1,
  "version_conflicts": 1000,
  "noops": 0,
  "retries": {
    "bulk": 0,
    "search": 0
  },
  "throttled_millis": 0,
  "requests_per_second": -1,
  "throttled_until_millis": 0,
  "failures": [
    {
      "index": "indexName",
      "type": "typeName",
      "id": "HVBLdzwnImXdVbq",
      "cause": {
        "type": "version_conflict_engine_exception",
        "reason": "[typeName][HVBLdzwnImXdVbq]: version conflict, current version [2] is different than the one provided [1]",
        "index_uuid": "YPJcVQZqQKqnuhbC9R7qHA",
        "shard": "1",
        "index": "indexName"
      },
      "status": 409
    },....

1 个答案:

答案 0 :(得分:2)

请阅读this article

您有两种方法可以解决此问题,方法是将 url 设置为忽略版本冲突,或将查询设置为忽略版本冲突:

  

如果您想计算版本冲突而不是让它们中止,请在网址上设置conflicts=proceed或在请求正文中设置"conflicts": "proceed"