简体   繁体   English

使用Python的Elasticsearch批量响应

[英]Elasticsearch Bulk Response with Python

I have the following Python code to do a ElasticSearch batch update, and when I get back the response object, I got something very simple, and it doesn't look right to me, anything wrong here? 我有以下Python代码来进行ElasticSearch批处理更新,当我返回响应对象时,我得到了一些非常简单的信息,对我来说看起来不对,这里有什么问题吗?

...
actions = []
for item in data:
    actions.append({"_index": index,
                    "_type": doc_type,
                    "_id": item['id'],
                    "_source": item})

print ("batching result")
response = helpers.bulk(self.es.conn, actions)
print (response)

Here is the output, but I'm expecting something more detail. 这是输出,但是我希望有更多细节。

batching result
(2, [])

As written in documentation : 文档中所写:

It returns a tuple with summary information - number of successfully executed actions and either list of errors or number of errors if stats_only is set to True [...] If you need to process a lot of data and want to ignore/collect errors please consider using the streaming_bulk() helper which will just return the errors and not store them in memory. 它返回一个带有摘要信息的元组-成功执行的操作数以及错误列表或错误数(如果stats_only设置为True [...])如果您需要处理大量数据并想要忽略/收集错误,请...考虑使用streaming_bulk()帮助器,该帮助器将仅返回错误而不将其存储在内存中。

with streaming_bulk() you have to use raise_on_error parameter for raise on error. 对于streaming_bulk(),必须使用raise_on_error参数来引发错误。 if you want to collect a lot of data i suggest to use parallel_bulk() that is faster and more intuitive 如果您想收集很多数据,我建议使用parallel_bulk() ,它更快,更直观

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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