Add upsert description to Update document API information (#934)

* fix#755-Update-document-upserts

Signed-off-by: cwillum <cwmmoore@amazon.com>

* fix#755-Update-document-upserts

Signed-off-by: cwillum <cwmmoore@amazon.com>

* fix#755-Update-document-upserts

Signed-off-by: cwillum <cwmmoore@amazon.com>

Signed-off-by: cwillum <cwmmoore@amazon.com>
This commit is contained in:
Chris Moore 2022-08-22 13:10:29 -07:00 committed by GitHub
parent 7e5a84d3f8
commit f32c849c93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,6 +87,35 @@ You can also use a script to tell OpenSearch how to update your document.
}
```
### Upsert
Upsert is an operation that conditionally either updates an existing document or inserts a new one based on information in the object. In the sample below, the `upsert` object updates the last name and adds the `age` field if a document already exists. If a document does not exist, a new one is indexed using content in the `upsert` object.
```json
{
"doc": {
"first_name": "Martha",
"last_name": "Rivera"
},
"upsert": {
"last_name": "Oliveira",
"age": "31"
}
}
```
You can also add `doc_as_upsert` to the request and set it to `true` to use the information in `doc` for performing the upsert operation.
```json
{
"doc": {
"first_name": "Martha",
"last_name": "Oliveira",
"age": "31"
},
"doc_as_upsert": true
}
```
## Response
```json
{