2017-03-20 58 views
1

IAM使用此代码删除我的索引文档:Elaticsearch 5.2,Python 3中AttributeError的: 'Elasticsearch' 对象有没有属性 'delete_by_query'

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

您使用的是什么版本的Python 3.X?我已经使用相同的代码在Python 3.5.2上运行它,并找到该函数。 – KeirDavis

+0

@KeirDavis:使用Python的Iam 2.7.9 python -V Python 2.7.9 – AhmyOhlin

回答

相关问题