Update a document by running a script or passing a partial document.
If the Elasticsearch security features are enabled, you must have the index or write index privilege for the target index or index alias.
The script can update, delete, or skip modifying the document.
The API also supports passing a partial document, which is merged into the existing document.
To fully replace an existing document, use the index API.
This operation:
Gets the document (collocated with the shard) from the index.
Runs the specified script.
Indexes the result.
The document must still be reindexed, but using this API removes some network roundtrips and reduces chances of version conflicts between the GET and the index operation.
The _source field must be enabled to use this API.
In addition to _source, you can access the following variables through the ctx map: _index, _type, _id, _version, _routing, and _now (the current timestamp).
For usage examples such as partial updates, upserts, and scripted updates, see the External documentation.
Only perform the operation if the document has this primary term.
if_seq_nonumber
Only perform the operation if the document has this sequence number.
include_source_on_errorboolean · default: true
True or false if to include the document source in the error message in case of parsing errors.
langstring · default: painless
The script language.
refreshenum · default: false
If 'true', Elasticsearch refreshes the affected shards to make this operation visible to search.
If 'wait_for', it waits for a refresh to make this operation visible to search.
If 'false', it does nothing with refreshes.
Values:truefalsewait_for
require_aliasboolean · default: false
If true, the destination must be an index alias.
retry_on_conflictnumber · default: 0
The number of times the operation should be retried when a conflict occurs.
timeoutuniononeOf · default: 1m
The period to wait for the following operations: dynamic mapping updates and waiting for active shards.
Elasticsearch waits for at least the timeout period before failing.
The actual wait time could be longer, particularly when multiple waits occur.
Values:-10
_sourceuniononeOf · default: true
If false, source retrieval is turned off.
You can also specify a comma-separated list of the fields you want to retrieve.
The primary term assigned to the document for the indexing operation.
resultenumrequired
The result of the indexing operation: created or updated.
Values:createdupdateddeletednot_foundnoop
_seq_nonumber
The sequence number assigned to the document for the indexing operation.
Sequence numbers are used to ensure an older version of a document doesn't overwrite a newer version.
_shardsobjectrequired
Information about the replication process of the operation.
failednumberrequired
The number of shards the operation or search attempted to run on but failed.
successfulnumberrequired
The number of shards the operation or search succeeded on.
totalnumberrequired
The number of shards the operation or search will run on overall.
failuresobject[]
indexstring
nodestring
reasonobjectrequired
typestringrequired
The type of error
reasonunionstringnullable
A human-readable explanation of the error, in English.
One of:string
stack_tracestring
The server stack trace. Present only if the error_trace=true parameter was sent with the request.