Skip to content

Commit 2efba7e

Browse files
Richard Smithfxdgear
Richard Smith
authored andcommitted
Update helpers.rst (elastic#965)
1 parent a29ea99 commit 2efba7e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/helpers.rst

+17
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ document is like ``{"word": "<myword>"}``.
9393
For a more complete and complex example please take a look at
9494
https://github.com/elastic/elasticsearch-py/blob/master/example/load.py#L76-L130
9595

96+
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.
97+
98+
To see the results use:
99+
100+
.. code:: python
101+
102+
for success, info in parallel_bulk(...):
103+
if not success:
104+
print('A document failed:', info)
105+
106+
If you don't care about the results, you can use deque from collections:
107+
108+
.. code:: python
109+
110+
from collections import deque
111+
deque(parallel_bulk(...), maxlen=0)
112+
96113
.. note::
97114

98115
When reading raw json strings from a file, you can also pass them in

0 commit comments

Comments
 (0)