aioes' delete_by_query'方法不起作用

时间:2016-10-10 08:01:11

标签: elasticsearch python-3.5

我的弹性中有几个单词,当我搜索“匹配”时,会显示出来。关键字。

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

但是当我想通过' _id'删除它们时它没有找到并向我显示这个错误:

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

错误:

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}}')

1 个答案:

答案 0 :(得分:1)

Elasticsearch删除了版本2.0中的查询删除功能,并将其添加为plugin,如果您想使用此功能,则必须安装该版本。

由于您已经拥有文档ID,因此如果您通过id而不是查询删除这些文档会更好。我认为在Python扩展中这样做的方法是

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