私はこのコードをpythonで使って、elasticsearchのドキュメントを更新しています。正常に動作していますが、毎回id
の値を初期化してすべてのドキュメントを更新する必要があるため、数百万のドキュメントに使用するのは難しいです。Elastisearch update by query
from elasticsearch import Elasticsearch, exceptions
elasticsearch = Elasticsearch()
elasticsearch.update(index='testindex', doc_type='AAA', id='AVpwMmhnpIpyZkmdMQkT',
body={
'doc':{'Device': 'updated'}
}
)
私はそれがまだ含まれているが、いないことをElasticsearchのドキュメントを読み込む: update_by_query
(ないupdate
)を使用してhttps://www.elastic.co/guide/en/elasticsearch/reference/current/_updating_documents.html
Note that as of this writing, updates can only be performed on a single document at a time. In the future, Elasticsearch might provide the ability to update multiple documents given a query condition (like an SQL UPDATE-WHERE statement).
私は、qが動作するはずのパラメータとして取得する 'update_by_query'がかなり確実です。 pythonのためにこれをチェックしてください。http://elasticsearch-py.readthedocs.io/en/master/api.html#elasticsearch.Elasticsearch.update_by_query – christinabo
こんにちはAhmyOhlinとサイトにようこそ。私はあなたの質問を編集して、このサイトの他の質問のフォーマットと一致させて、もう一度編集してください。 – MackM
@christinabo 私はDeviceの値を 'Boiler'から 'Test'に変更したいと思っています。 パラメータq = 'Device: "Boiler"を使用してすべてのドキュメントを値' boiler 'で更新しましたが、次のエラーが発生しました: TypeError:update()は予期しないキーワード引数' q 'を持っています これは私のコードです { 'doc':{'デバイス': 'テスト'} } ' – AhmyOhlin