How to use Python Elasticsearch mget () API

I want to get documents with multiple identifiers using the python _mget elasticsearch API.

I am using the es.mget() method for an Elasticsearch object. However, I do not know what needs to be provided as an argument regarding the body. whether it should be separated by a comma-separated list of identifiers or a list of documents with the specified _id .

I tried in both directions and I get an exception:

elasticsearch.exceptions.RequestError

+6
source share
1 answer

mget() used when retrieving multiple documents through a document id. You must pass body = {'ids': [doc_id1, doc_id2]} as described by ES Multi GET API

  es_client.mget(index = 'bank', doc_type = 'account', body = {'ids': ['100', '101']}) 
+7
source

All Articles