Skip to content

Commit 37b4ef6

Browse files
georgewallacethekofimensahleemthompo
authored
[DOCS] Upsert documentation clarification (#120684) (#121133)
Co-authored-by: Kofi B <[email protected]> Co-authored-by: Liam Thompson <[email protected]>
1 parent 182cba3 commit 37b4ef6

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

docs/reference/docs/update.asciidoc

+7-11
Original file line numberDiff line numberDiff line change
@@ -307,23 +307,19 @@ POST test/_update/1
307307
[discrete]
308308
===== Upsert
309309

310-
If the document does not already exist, the contents of the `upsert` element
311-
are inserted as a new document. If the document exists, the
312-
`script` is executed:
310+
An upsert operation lets you update an existing document or insert a new one if it doesn't exist, in a single request.
311+
312+
In this example, if the product with ID `1` exists, its price will be updated to `100`. If the product does not exist, a new document with ID `1` and a price of `50` will be inserted.
313313

314314
[source,console]
315315
----
316-
POST test/_update/1
316+
POST /test/_update/1
317317
{
318-
"script": {
319-
"source": "ctx._source.counter += params.count",
320-
"lang": "painless",
321-
"params": {
322-
"count": 4
323-
}
318+
"doc": {
319+
"product_price": 100
324320
},
325321
"upsert": {
326-
"counter": 1
322+
"product_price": 50
327323
}
328324
}
329325
----

0 commit comments

Comments
 (0)