Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't delete item in Elasticsearch with _delete_by_query

I would like to delete some items in Elasticsearch database according simple condition. I try to do it via Postman app. So I have a POST request to this url localhost:9200/newlocalsearch/_delete_by_query with this json query:

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

But as I send request to database it returns this error response:

{
    "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
        }
    ]
}

I dont understand what happens. Is there anybody out there :) who knows what it means? Thanks a lot.

like image 844
Čamo Avatar asked Nov 17 '22 00:11

Čamo


1 Answers

It could be you need to refresh your index first:

Send a POST request to localhost:9200/newlocalsearch/_refresh

like image 64
Patrick64 Avatar answered Jan 02 '23 19:01

Patrick64