0

I am getting below error while trying to delete the data of an Index in ES which I am not able to resolve.

code snippet:

from elasticsearch import Elasticsearch
ES_HOST = {"host" : "localhost", "port" : 9200}

start_datetime = "2020-12-23 00:00:00"
end_datetime = "2020-12-24 00:00:00"

es = Elasticsearch(hosts = [ES_HOST])
es.delete_by_query(index = INDEX_NAME, body = {
      "query": {
                "bool": {
                    "should": [{
                        "range": {
                             "recorddate": {
                                "gte": str(start_datetime),
                                "lt": str(end_datetime)
                            }
                        }
                    }]
                }
            }
  })

elasticsearch.exceptions.ConflictError: ConflictError(409, u'{"took":719,"timed_out":false,"total":527871,"deleted":0,"batches":1,"version_conflicts":1000,"noops":0,"retries":{"bulk":0,"search":0},"throttled_millis":0,"requests_per_second":-1.0,"throttled_until_millis":0,"failures":[]}

ES Document reference : https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html

Other references used for using in python : https://python.hotexamples.com/examples/elasticsearch/Elasticsearch/delete_by_query/python-elasticsearch-delete_by_query-method-examples.html

Alaric
  • 19
  • 4
  • Do you understand what the error message means? – mkrieger1 Feb 12 '21 at 21:19
  • @mkrieger1 No, I am able to delete the data with normal curl command , but not with this function – Alaric Feb 14 '21 at 16:58
  • Does this answer your question? [Version conflict when using the delete method of elasticsearch-dsl](https://stackoverflow.com/questions/56840637/version-conflict-when-using-the-delete-method-of-elasticsearch-dsl) – mkrieger1 Feb 14 '21 at 17:00
  • But why dont I run into this issue when I use the below query. This works from my python script,but the above method I use from the elasticsearch package:``` "query": { "bool": { "should": [{ "range": { "recorddate": { "gte": "''' + str(prev_datetime) + '''", "lt": "''' + str(end_datetime) + '''" } } }] } } } ``` – Alaric Feb 16 '21 at 11:00

0 Answers0