mortymacs
mortymacs

Reputation: 3736

aioes 'delete_by_query' method doesn't work

I have several words in my elastic which shows when I search by 'match' keyword.

{
   "took": 3,
   "timed_out": false,
   "_shards": {
      "total": 10,
      "successful": 10,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": 0.30685282,
      "hits": [
         {
            "_index": "my_words_pack",
            "_type": "work_g1",
            "_id": "AVetfhx1AM1sow6PcrL0",
            "_score": 0.30685282,
            "_source": {
               "keyword": "morteza"
            }
         }
      ]
   }
}

but when I want to remove them by '_id' it doesn't work find and shows me this error:

es.delete_by_query(index='my_words_pack', doc_type='work_g1' body={"query": {"match": {"_id": "AVetfhx1AM1sow6PcrL0"}}})

Error:

aioes.exception.NotFoundError: TransportError(404, '{"found":false,"_index":"my_words_pack","_type":"work_g1","_id":"_query","_version":1,"_shards":{"total":2,"successful":1,"failed":0}}')

Upvotes: 0

Views: 182

Answers (1)

Or Weinberger
Or Weinberger

Reputation: 7472

Elasticsearch removed the delete by query ability in version 2.0 and added it as a plugin that you must install if you would like to use this ability.

Since you already have the document IDs, its better if you delete these documents by id rather than by query. I think the way to do it in the Python extension is

es.delete(index="my_words_pack",doc_type="work_g1",id="AVetfhx1AM1sow6PcrL0")

Upvotes: 2

Related Questions