简体   繁体   中英

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?

...
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.

with streaming_bulk() you have to use raise_on_error parameter for raise on error. if you want to collect a lot of data i suggest to use parallel_bulk() that is faster and more intuitive

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