Add examples for bulk script & upsert updates (#783)

There is no mention of doc_as_upsert in OS documention, but it appears to be supported. Some examples to go along with the passing mention of scripts & especially upsert would go a long way
This also addresses #755

Signed-off-by: Alek Poteet <patrick.poteet@shipveho.com>

Signed-off-by: Alek Poteet <patrick.poteet@shipveho.com>
This commit is contained in:
Alek Poteet 2022-08-23 19:58:03 -06:00 committed by GitHub
parent 906a81bca7
commit d417b5d85a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -103,13 +103,26 @@ All actions support the same metadata: `_index`, `_id`, and `_require_alias`. If
- Update
This action updates existing documents and returns an error if the document doesn't exist. The next line must include a full or partial JSON document, depending on how much of the document you want to update. It can also include a script or upsert for more complex document updates.
This action updates existing documents and returns an error if the document doesn't exist. The next line must include a full or partial JSON document, depending on how much of the document you want to update.
```json
{ "update": { "_index": "movies", "_id": "tt0816711" } }
{ "doc" : { "title": "World War Z" } }
```
It can also include a script or upsert for more complex document updates.
- Script
```json
{ "update": { "_index": "movies", "_id": "tt0816711" } }
{ "script" : { "source": "ctx._source.title = \"World War Z\"" } }
```
- Upsert
```json
{ "update": { "_index": "movies", "_id": "tt0816711" } }
{ "doc" : { "title": "World War Z" }, "doc_as_upsert": true }
```
## Response