File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,29 @@ action (``_op_type`` defaults to ``index``):
6969 }
7070
7171
72+ Example:
73+ ~~~~~~~~
74+
75+ Lets say we have an iterable of data. Lets say a list of words called ``mywords ``
76+ and we want to index those words into individual documents where the structure of the
77+ document is like ``{"word": "<myword>"} ``.
78+
79+ .. code :: python
80+
81+ def gendata ():
82+ mywords = [' foo' , ' bar' , ' baz' ]
83+ for word in mywords:
84+ yield {
85+ " _index" : " mywords" ,
86+ " doc" : {" word" : myword},
87+ }
88+
89+ bulk(es, gendata)
90+
91+
92+ For a more complete and complex example please take a look at
93+ https://github.com/elastic/elasticsearch-py/blob/master/example/load.py#L76-L130
94+
7295.. note ::
7396
7497 When reading raw json strings from a file, you can also pass them in
You can’t perform that action at this time.
0 commit comments