5

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.

Čamo
  • 3,863
  • 13
  • 62
  • 114
  • 2
    Try add as get parameter 'conflicts=proceed&refresh=wait_for' – rad11 Oct 15 '18 at 19:19
  • What it means. Why my POST request is not able to do it? I need to understand what happend. – Čamo Oct 15 '18 at 19:36
  • 1
    https://www.elastic.co/guide/en/elasticsearch/guide/current/optimistic-concurrency-control.html, https://discuss.elastic.co/t/version-conflict-while-using-delete-by-query/104831 – rad11 Oct 15 '18 at 19:41
  • 3
    `?conflicts=proceed&refresh&slices=5` run it using slices – ben5556 Oct 15 '18 at 22:50

1 Answers1

1

It could be you need to refresh your index first:

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

Patrick64
  • 430
  • 6
  • 12