Update a document Beta
Updates a document by running a script or passing a partial document.
Path parameters
-
The name of the index
-
Document ID
Query parameters
-
if_primary_term number
Only perform the operation if the document has this primary term.
-
if_seq_no number
Only perform the operation if the document has this sequence number.
-
lang string
The script language.
-
refresh string
If 'true', Elasticsearch refreshes the affected shards to make this operation visible to search, if 'wait_for' then wait for a refresh to make this operation visible to search, if 'false' do nothing with refreshes.
Values are
true
,false
, orwait_for
. -
require_alias boolean
If true, the destination must be an index alias.
-
retry_on_conflict number
Specify how many times should the operation be retried when a conflict occurs.
-
routing string
Custom value used to route operations to a specific shard.
-
timeout string
Period to wait for dynamic mapping updates and active shards. This guarantees Elasticsearch waits for at least the timeout before failing. The actual wait time could be longer, particularly when multiple waits occur.
-
wait_for_active_shards number | string
The number of shard copies that must be active before proceeding with the operations. Set to 'all' or any positive integer up to the total number of shards in the index (number_of_replicas+1). Defaults to 1 meaning the primary shard.
-
_source boolean | string | array[string]
Set to false to disable source retrieval. You can also specify a comma-separated list of the fields you want to retrieve.
-
_source_excludes string | array[string]
Specify the source fields you want to exclude.
-
_source_includes string | array[string]
Specify the source fields you want to retrieve.
Body Required
-
detect_noop boolean
Set to false to disable setting 'result' in the response to 'noop' if no change to the document occurred.
-
doc object
A partial update to an existing document.
Additional properties are allowed.
-
doc_as_upsert boolean
Set to true to use the contents of 'doc' as the value of 'upsert'
-
script object
Additional properties are allowed.
-
scripted_upsert boolean
Set to true to execute the script whether or not the document exists.
_source boolean | object
Defines how to fetch a source. Fetching can be disabled entirely, or the source can be filtered.
-
upsert object
If the document does not already exist, the contents of 'upsert' are inserted as a new document. If the document exists, the 'script' is executed.
Additional properties are allowed.
curl \
-X POST http://api.example.com/{index}/_update/{id} \
-H "Content-Type: application/json" \
-d '{"detect_noop":true,"doc":{},"doc_as_upsert":true,"script":{"source":"string","id":"string","params":{"additionalProperty1":{},"additionalProperty2":{}},"":"painless","options":{"additionalProperty1":"string","additionalProperty2":"string"}},"scripted_upsert":true,"":true,"upsert":{}}'