试图让批量过滤功能在Elasticsearch-py (即mpercolate)上工作,但在网上找不到一个例子。我可以使用percolate函数,所以我可以让它工作:
doc = {'doc' : {'field1' : 'this is a value', 'field2' : 'this is another value'}}
res = es.percolate(index = 'my_index', doc_type = 'my_doc_type', body = doc)到目前为止,我读过的文档似乎暗示,如果我想进行批量提交,我需要将header和body作为字符串发送,并用换行符分隔。因此,我尝试了:
head = {'percolate' : {'index' : 'my_index', 'type' : 'my_doc_type'}}
doc = {'doc' : {'field1' : 'this is a value', 'field2' : 'this is another value'}}
doc2 = {'doc' : {'field1' : 'values and values', 'field2' : 'billions of values'}}
query_list = [head, doc, head, doc2]
my_body = '\n'.join([str(qry) for qry in query_list])
res = es.mpercolate(body = my_body)这给了我一个通用的"elasticsearch.exceptions.TransportError“。谁有我可以改编的工作示例?
发布于 2017-04-26 00:39:59
您不必自己序列化数据,只需将query_list作为主体传入,它就会做正确的事情
https://stackoverflow.com/questions/43591687
复制相似问题