Skip to content

Commit

Permalink
Update guides-bulk example (opensearch-project#774)
Browse files Browse the repository at this point in the history
Fixed examples to make them working python code. (missing commas and quotes.

Signed-off-by: Keith Rozario <795867+keithrozario@users.noreply.github.com>
  • Loading branch information
keithrozario authored and dblock committed Aug 15, 2024
1 parent 80c4e71 commit 25b4e88
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions guides/bulk.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
]

Expand All @@ -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)
Expand Down

0 comments on commit 25b4e88

Please sign in to comment.