From 1fbddfa620c3d71972cea6748f9224ca14c6d038 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 31 May 2019 12:45:59 +0100 Subject: [PATCH] Update helpers.rst --- docs/helpers.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/helpers.rst b/docs/helpers.rst index c1b52608f..2202e9bca 100644 --- a/docs/helpers.rst +++ b/docs/helpers.rst @@ -93,6 +93,23 @@ document is like ``{"word": ""}``. For a more complete and complex example please take a look at https://github.com/elastic/elasticsearch-py/blob/master/example/load.py#L76-L130 +The :meth:`~elasticsearch.Elasticsearch.parallel_bulk` api is a wrapper around the :meth:`~elasticsearch.Elasticsearch.bulk` api to provide threading. :meth:`~elasticsearch.Elasticsearch.parallel_bulk` returns a generator which must be consumed to produce results. + +To see the results use: + +.. code:: python + + for success, info in parallel_bulk(...): + if not success: + print('A document failed:', info) + +If you don't care about the results, you can use deque from collections: + +.. code:: python + + from collections import deque + deque(parallel_bulk(...), maxlen=0) + .. note:: When reading raw json strings from a file, you can also pass them in