如何使用Python Elasticsearch mget()API

Vai*_*hek 8 python elasticsearch

我想使用elasticsearch python的_mget API获取具有多个id的文档.

我在es.mget()Elasticsearch对象上使用方法.但是,我不知道提供什么作为身体参数的论据.它应该是逗号分隔的ID列表还是_id提到的文档列表.

我尝试了两种方式,并且一直收到异常:

elasticsearch.exceptions.RequestError

Jas*_*Heo 14

mget()通过文档ID检索多个文档时使用.您应该通过body = {'ids': [doc_id1, doc_id2]}描述ES Multi GET API传递

 es_client.mget(index = 'bank',
                doc_type = 'account',
                body = {'ids': ['100', '101']})
Run Code Online (Sandbox Code Playgroud)