elasticsearch/elasticsearch-py — pull request #14 by miku (2013-10-17 15:05:44+00:00)
Title: Allow `bulk_index` to take a `callback` kwarg.

I came across a use case for this, but I am not sure how useful it is in general - just I thought I just put it up to discussion.

Allow `elasticsearch.helper.bulk_index` to take a keyword
argument `callback`, which must be a callable, that takes three arguments:
`success`, `failed`, `errors`. The callback is called after each
bulk operation and can be used to collect and display progress information.

Example:

...
def progress(success, failed, errors):
print('%s indexed' % success)

bulk_index(es, docs, chunk_size=2000, callback=progress,
raise_on_error=True)
...