6
6
7
7
Updates a document using the specified script.
8
8
9
+ [[docs-update-api-request]]
10
+ ==== {api-request-title}
11
+
12
+ `POST /<index/_update/<_id>`
13
+
14
+ [[docs-update-api-path-params]]
15
+ ==== {api-path-parms-title}
16
+
17
+ `<index>`::
18
+ (Required, string) Name of the target index. By default, the index is created
19
+ automatically if it doesn't exist. For more information, see <<index-creation>>.
20
+
21
+ `<_id>`::
22
+ (Required, string) Unique identifier for the document to be updated.
9
23
10
24
[[docs-update-api-query-params]]
11
25
==== {api-query-parms-title}
12
26
27
+ include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-seq-no]
28
+
29
+ include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-primary-term]
30
+
13
31
`lang`::
14
32
(Optional, string) The script language. Default: `painless`.
15
33
@@ -19,46 +37,39 @@ include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-refresh]
19
37
(Optional, integer) Specify how many times should the operation be retried when
20
38
a conflict occurs. Default: 0.
21
39
22
- In between the get and indexing phases of the update, it is possible that
23
- another process might have already updated the same document. By default, the
24
- update will fail with a version conflict exception. The `retry_on_conflict`
25
- parameter controls how many times to retry the update before finally throwing
26
- an exception.
27
-
28
40
include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-refresh]
29
41
30
42
include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-routing]
31
43
32
- include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-source]
44
+ `_source`::
45
+ (Optional, list) Set to `false` to disable source retrieval (default: `true`).
46
+ You can also specify a comma-separated list of the fields you want to retrieve.
33
47
34
- include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-source-excludes]
48
+ `_source_excludes`::
49
+ (Optional, list) Specify the source fields you want to exclude.
35
50
36
- include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-source-includes]
51
+ `_source_includes`::
52
+ (Optional, list) Specify the source fields you want to retrieve.
37
53
38
54
include::{docdir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
39
55
40
- include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-seq-no]
41
-
42
- include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-primary-term]
43
-
44
56
include::{docdir}/rest-api/common-parms.asciidoc[tag=doc-wait-for-active-shards]
45
57
46
58
47
59
[[update-api-desc]]
48
60
==== {api-description-title}
49
61
50
- Enables you script document updates. This operation:
62
+ Enables you script document updates. The script can update, delete, or skip
63
+ modifying the document. The update API also supports passing a partial document,
64
+ which is merged into the existing document. To fully replace an existing
65
+ document, use the <<docs-index_,`index` API>>.
66
+
67
+ This operation:
51
68
52
69
. Gets the document (collocated with the shard) from the index.
53
70
. Runs the specified script.
54
71
. Indexes the result.
55
72
56
- The script can update, delete, or skip modifying the document.
57
-
58
- The update API also supports passing a partial document,
59
- which is merged into the existing document. To fully replace an existing
60
- document, use the <<docs-index_,`index` API>> instead.
61
-
62
73
The document must still be reindexed, but using `update` removes some network
63
74
roundtrips and reduces chances of version conflicts between the GET and the
64
75
index operation.
@@ -266,7 +277,7 @@ POST test/_update/1
266
277
267
278
[[upserts]]
268
279
[float]
269
- ==== Upsert
280
+ ===== Upsert
270
281
271
282
If the document does not already exist, the contents of the `upsert` element
272
283
are inserted as a new document. If the document exists, the
0 commit comments