Update guides-bulk example (#774)

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

Signed-off-by: Keith Rozario <795867+keithrozario@users.noreply.github.com>
This commit is contained in:
Keith Rozario
2024-07-14 22:27:35 +08: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
data = [
{ "index": { "_index": "index-2022-06-08", "_id": 1 }}
{ "name": "foo"}
{ "index": { "_index": "index-2022-06-09", "_id": 2 }}
{ "name": "bar"}
{ "index": { "_index": "index-2022-06-10", "_id": 3 }}
{ "index": { "_index": "index-2022-06-08", "_id": 1 }},
{ "name": "foo"},
{ "index": { "_index": "index-2022-06-09", "_id": 2 }},
{ "name": "bar"},
{ "index": { "_index": "index-2022-06-10", "_id": 3 }},
{ "name": "baz"}
]
@@ -64,9 +64,9 @@ from opensearchpy import OpenSearch, helpers
client = OpenSearch(...)
docs = [
{ "_index": "words", "_id": "word1", word: "foo" },
{ "_index": "words", "_id": "word2", word: "bar" },
{ "_index": "words", "_id": "word3", word: "baz" },
{ "_index": "words", "_id": "word1", "word": "foo" },
{ "_index": "words", "_id": "word2", "word": "bar" },
{ "_index": "words", "_id": "word3", "word": "baz" },
]
response = helpers.bulk(client, docs, max_retries=3)