首页 > 解决方案 > 无法使用 _delete_by_query 删除 Elasticsearch 中的项目

问题描述

我想根据简单的条件删除 Elasticsearch 数据库中的一些项目。我尝试通过Postman应用程序来完成。所以我对这个 url localhost:9200/newlocalsearch/_delete_by_query有一个 POST 请求,带有这个 json 查询:

{
    "query": {
        "bool": {
            "must_not": [
                {"exists": {"field": "ico"}}
            ]
        }
    }
}

但是当我向数据库发送请求时,它会返回此错误响应:

{
    "took": 51,
    "timed_out": false,
    "total": 1,
    "deleted": 0,
    "batches": 1,
    "version_conflicts": 1,
    "noops": 0,
    "retries": {
        "bulk": 0,
        "search": 0
    },
    "throttled_millis": 0,
    "requests_per_second": -1,
    "throttled_until_millis": 0,
    "failures": [
        {
            "index": "newlocalsearch",
            "type": "doc",
            "id": "0",
            "cause": {
                "type": "version_conflict_engine_exception",
                "reason": "[doc][0]: version conflict, current version [-1] is different than the one provided [1]",
                "index_uuid": "jZbdUfqwSAqtFELXB2Z2AQ",
                "shard": "0",
                "index": "newlocalsearch"
            },
            "status": 409
        }
    ]
}

我不明白会发生什么。有没有人在那里:) 谁知道这意味着什么?非常感谢。

标签: elasticsearchhttp-delete

解决方案


您可能需要先刷新索引:

发送POST请求至localhost:9200/newlocalsearch/_refresh


推荐阅读