2017-03-20 5 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

答えて

2

https://github.com/elastic/elasticsearch-py/blob/master/elasticsearch/client/init.pyのコードを確認しました。Elasticsearchクラスにはdelete_by_queryメソッドが含まれています。だから、これは起こってはならない。古いバージョン(< 5.0)からelasticsearch-pyをアップグレードし、古いPythonライブラリファイルを削除しない可能性があります。 elasticsearch-pyモジュールを取り外して再インストールしてみてください。これは修正する必要があります。

+0

ありがとう。問題はあなたの助言によって解決される – AhmyOhlin

関連する問題