Update guides-bulk example (#774)

Fixed examples to make them working python code. (missing commas and quotes.

Signed-off-by: Keith Rozario <[email protected]>
This commit is contained in:
Keith Rozario
2024-07-14 10:27:35 -04:00
committed by GitHub
parent 04a2350ba0
commit a380e7083f
+8 -8
View File
@@ -37,11 +37,11 @@ The client can also serialize an array of data into bulk-delimited JSON for you.
```python ```python
data = [ data = [
{ "index": { "_index": "index-2022-06-08", "_id": 1 }} { "index": { "_index": "index-2022-06-08", "_id": 1 }},
{ "name": "foo"} { "name": "foo"},
{ "index": { "_index": "index-2022-06-09", "_id": 2 }} { "index": { "_index": "index-2022-06-09", "_id": 2 }},
{ "name": "bar"} { "name": "bar"},
{ "index": { "_index": "index-2022-06-10", "_id": 3 }} { "index": { "_index": "index-2022-06-10", "_id": 3 }},
{ "name": "baz"} { "name": "baz"}
] ]
@@ -64,9 +64,9 @@ from opensearchpy import OpenSearch, helpers
client = OpenSearch(...) client = OpenSearch(...)
docs = [ docs = [
{ "_index": "words", "_id": "word1", word: "foo" }, { "_index": "words", "_id": "word1", "word": "foo" },
{ "_index": "words", "_id": "word2", word: "bar" }, { "_index": "words", "_id": "word2", "word": "bar" },
{ "_index": "words", "_id": "word3", word: "baz" }, { "_index": "words", "_id": "word3", "word": "baz" },
] ]
response = helpers.bulk(client, docs, max_retries=3) response = helpers.bulk(client, docs, max_retries=3)