简体   繁体   中英

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

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']})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM