gpt4 book ai didi

python - Elasticsearch 5.2、Python 3 属性错误 : 'Elasticsearch' object has no attribute 'delete_by_query'

转载 作者:行者123 更新时间:2023-12-01 03:10:48 25 4
gpt4 key购买 nike

iam 使用此代码从我的索引中删除文档:

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'

有人遇到过这个问题吗?有什么帮助吗?谢谢

最佳答案

我已经检查了 https://github.com/elastic/elasticsearch-py/blob/master/elasticsearch/client/init.py 上的代码Elasticsearch 类包含 delete_by_query 方法。所以这不应该发生。可能的原因是您从旧版本(<5.0)升级了elasticsearch-py,并且旧的python库文件没有被删除。尝试删除elasticsearch-py模块并重新安装,这应该可以解决。

关于python - Elasticsearch 5.2、Python 3 属性错误 : 'Elasticsearch' object has no attribute 'delete_by_query' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42901766/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com