我使用此代码从我的索引中删除文档:
from elasticsearch import Elasticsearch
es= Elasticsearch()
index = 'test'
doc_type = 'trends'
q = {
"query": {
"match": {
"Device": "12 Bel"
# find the docs those schould be deleted
}
},
}
result = es.delete_by_query(body=q, doc_type=doc_type, index=index)
print('Result is : ', result)
我收到此错误:
AttributeError: 'Elasticsearch' object has no attribute 'delete_by_query'
有人遇到过这个问题吗?有帮助吗? 感谢
答案 0 :(得分:2)
我已检查https://github.com/elastic/elasticsearch-py/blob/master/elasticsearch/client/init.py上的代码,Elasticsearch
类包含delete_by_query
方法。所以这不应该发生。可能的原因是您从旧版本(< 5.0)升级了elasticsearch-py,并且未删除旧的python库文件。尝试删除elasticsearch-py模块并重新安装,这应该是固定的。