Update documents | Elasticsearch API documentation (original) (raw)
Dismiss highlight Show more
Path parameters
- index
string | array[string] Required
A comma-separated list of data streams, indices, and aliases to search. It supports wildcards (*
). To search all data streams or indices, omit this parameter or use*
or_all
.
Query parameters
- If
false
, the request returns an error if any wildcard expression, index alias, or_all
value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targetingfoo*,bar*
returns an error if an index starts withfoo
but no index starts withbar
. - The analyzer to use for the query string. This parameter can be used only when the
q
query string parameter is specified. - If
true
, wildcard and prefix queries are analyzed. This parameter can be used only when theq
query string parameter is specified. - The preferred behavior when update by query hits version conflicts:
abort
orproceed
.
Supported values include:abort
: Stop reindexing if there are conflicts.proceed
: Continue reindexing even if there are conflicts.
Values areabort
orproceed
.
- The default operator for query string query:
AND
orOR
. This parameter can be used only when theq
query string parameter is specified.
Values areand
,AND
,or
, orOR
. - The field to use as default where no field prefix is given in the query string. This parameter can be used only when the
q
query string parameter is specified. - The type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. It supports comma-separated values, such as
open,hidden
. Valid values are:all
,open
,closed
,hidden
,none
.
Supported values include:all
: Match any data stream or index, including hidden ones.open
: Match open, non-hidden indices. Also matches any non-hidden data stream.closed
: Match closed, non-hidden indices. Also matches any non-hidden data stream. Data streams cannot be closed.hidden
: Match hidden data streams and hidden indices. Must be combined withopen
,closed
, orboth
.none
: Wildcard expressions are not accepted.
- Skips the specified number of documents.
- If
false
, the request returns an error if it targets a missing or closed index. - If
true
, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. This parameter can be used only when theq
query string parameter is specified. - The maximum number of documents to process. It defaults to all documents. When set to a value less then or equal to
scroll_size
then a scroll will not be used to retrieve the results for the operation. - The ID of the pipeline to use to preprocess incoming documents. If the index has a default ingest pipeline specified, then setting the value to
_none
disables the default ingest pipeline for this request. If a final pipeline is configured it will always run, regardless of the value of this parameter. - The node or shard the operation should be performed on. It is random by default.
- A query in the Lucene query string syntax.
- If
true
, Elasticsearch refreshes affected shards to make the operation visible to search after the request completes. This is different than the update API'srefresh
parameter, which causes just the shard that received the request to be refreshed. - If
true
, the request cache is used for this request. It defaults to the index-level setting. - The throttle for this request in sub-requests per second.
- A custom value used to route operations to a specific shard.
- The period to retain the search context for scrolling.
- The size of the scroll request that powers the operation.
- An explicit timeout for each search request. By default, there is no timeout.
- The type of the search operation. Available options include
query_then_fetch
anddfs_query_then_fetch
.
Supported values include:query_then_fetch
: Documents are scored using local term and document frequencies for the shard. This is usually faster but less accurate.dfs_query_then_fetch
: Documents are scored using global term and document frequencies across all shards. This is usually slower but more accurate.
Values arequery_then_fetch
ordfs_query_then_fetch
.
- The number of slices this task should be divided into.
- A comma-separated list of : pairs.
- The specific
tag
of the request for logging and statistical purposes. - The maximum number of documents to collect for each shard. If a query reaches this limit, Elasticsearch terminates the query early. Elasticsearch collects documents before sorting.
IMPORTANT: Use with caution. Elasticsearch applies this parameter to each shard handling the request. When possible, let Elasticsearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers. - The period each update request waits for the following operations: dynamic mapping updates, waiting for active shards. By default, it is one minute. This guarantees Elasticsearch waits for at least the timeout before failing. The actual wait time could be longer, particularly when multiple waits occur.
- If
true
, returns the document version as part of a hit. - Should the document increment the version number (internal) on hit or not (reindex)
- The number of shard copies that must be active before proceeding with the operation. Set to
all
or any positive integer up to the total number of shards in the index (number_of_replicas+1
). Thetimeout
parameter controls how long each write request waits for unavailable shards to become available. Both work exactly the way they work in the bulk API. - If
true
, the request blocks until the operation is complete. Iffalse
, Elasticsearch performs some preflight checks, launches the request, and returns a task ID that you can use to cancel or get the status of the task. Elasticsearch creates a record of this task as a document at.tasks/task/${taskId}
.
application/json
Body
- The maximum number of documents to update.
- An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.
External documentation - Hide script attributes Show script attributes object
- Specifies any named parameters that are passed into the script as variables. Use parameters instead of hard-coded values to decrease compile time.
Hide params attribute Show params attribute object
* *
object Additional properties lang string
Values are
painless
,expression
,mustache
, orjava
.- Hide options attribute Show options attribute object
* *
string Additional properties
- Specifies any named parameters that are passed into the script as variables. Use parameters instead of hard-coded values to decrease compile time.
- Hide slice attributes Show slice attributes object
- Path to field or array of paths. Some API's support wildcards in the path to select multiple fields.
- Values are
abort
orproceed
.
Responses
- 200 application/json
Hide response attributes Show response attributes object- The number of scroll responses pulled back by the update by query.
- Array of failures if there were any unrecoverable errors during the process. If this is non-empty then the request ended because of those failures. Update by query is implemented using batches. Any failure causes the entire process to end, but all failures in the current batch are collected into the array. You can use the
conflicts
option to prevent reindex from ending when version conflicts occur.
Hide failures attributes Show failures attributes object
* Hide cause attributes Show cause attributes object
* The type of error
* A human-readable explanation of the error, in English.
* The server stack trace. Present only if theerror_trace=true
parameter was sent with the request. - The number of documents that were ignored because the script used for the update by query returned a noop value for
ctx.op
. - The number of documents that were successfully deleted.
- The number of requests per second effectively run during the update by query.
- Hide retries attributes Show retries attributes object
* The number of bulk actions retried.
* The number of search actions retried. task string | number
- If true, some requests timed out during the update by query.
- Time unit for milliseconds
- The number of documents that were successfully processed.
- The number of documents that were successfully updated.
- The number of version conflicts that the update by query hit.
- A duration. Units can be
nanos
,micros
,ms
(milliseconds),s
(seconds),m
(minutes),h
(hours) andd
(days). Also accepts "0" without a unit and "-1" to indicate an unspecified value. - Time unit for milliseconds
- A duration. Units can be
nanos
,micros
,ms
(milliseconds),s
(seconds),m
(minutes),h
(hours) andd
(days). Also accepts "0" without a unit and "-1" to indicate an unspecified value. - Time unit for milliseconds