[英]How to use Python Elasticsearch mget() API
I want to fetch documents with multiple ids using _mget API of elasticsearch python. 我想使用elasticsearch python的_mget API获取具有多个id的文档。
I'm using es.mget()
method on a Elasticsearch object. 我在Elasticsearch对象上使用es.mget()
方法。 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. 应该是逗号分隔的id列表还是带有_id
的文档列表。
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. 通过文档ID检索多个文档时使用mget()
。 You should pass body = {'ids': [doc_id1, doc_id2]}
as describe ES Multi GET API 你应该传递body = {'ids': [doc_id1, doc_id2]}
作为ES Multi GET API的描述
es_client.mget(index = 'bank',
doc_type = 'account',
body = {'ids': ['100', '101']})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.