Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Python Elasticsearch mget() API

I want to fetch documents with multiple ids using _mget API of elasticsearch python.

I'm using es.mget() method on a Elasticsearch object. However, I don't know what to provide as an argument to body param. should it be comma separated list of ids or a list of docs with _id mentioned.

I've tried both ways and I keep receiving an exception:

elasticsearch.exceptions.RequestError

like image 695
VaidAbhishek Avatar asked Feb 16 '16 19:02

VaidAbhishek


1 Answers

mget() is used when you retrieve multiple document via document id. You should pass body = {'ids': [doc_id1, doc_id2]} as describe ES Multi GET API

 es_client.mget(index = 'bank',
                doc_type = 'account',
                body = {'ids': ['100', '101']})
like image 51
Jason Heo Avatar answered Oct 31 '22 19:10

Jason Heo