Menu
Update documents
Update documents
/{index}/_update_by_queryUse it in a workflow
- Add a step and choose the Elasticsearch connector.
- Pick the Update documents action (under document).
- Fill in the fields below, then reference the result from later steps as
{{updateDocuments.response.data}}.
Request
Path parameters
indexoneOfrequiredA 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
allow_no_indicesbooleanA setting that does two separate checks on the index expression. If `false`, the request returns an error (1) if any wildcard expression (including `_all` and `*`) resolves to zero matching indices or (2) if the complete set of resolved indices, aliases or data streams is empty after all expressions are evaluated. If `true`, index expressions that resolve to no indices are allowed and the request returns an empty result.
analyzerstringThe analyzer to use for the query string. This parameter can be used only when the `q` query string parameter is specified.
analyze_wildcardbooleanIf `true`, wildcard and prefix queries are analyzed. This parameter can be used only when the `q` query string parameter is specified.
conflictsstringThe preferred behavior when update by query hits version conflicts: `abort` or `proceed`.
One ofabortproceed
default_operatorstringThe default operator for query string query: `and` or `or`. This parameter can be used only when the `q` query string parameter is specified.
One ofandANDorOR
dfstringThe 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.
expand_wildcardsoneOfThe 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`.
fromnumberSkips the specified number of documents.
ignore_unavailablebooleanIf `false`, the request returns an error if it targets a concrete (non-wildcarded) index, alias, or data stream that is missing, closed, or otherwise unavailable. If `true`, unavailable concrete targets are silently ignored.
lenientbooleanIf `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 the `q` query string parameter is specified.
max_docsnumberThe maximum number of documents to process. It defaults to all documents. When set to a value less than or equal to `scroll_size` and `conflicts` is set to `abort`, a scroll will not be used to retrieve the results for the operation.
pipelinestringThe 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.
preferencestringThe node or shard the operation should be performed on. It is random by default.
qstringA query in the Lucene query string syntax.
refreshbooleanIf `true`, Elasticsearch refreshes affected shards to make the operation visible to search after the request completes. This is different than the update API's `refresh` parameter, which causes just the shard that received the request to be refreshed.
request_cachebooleanIf `true`, the request cache is used for this request. It defaults to the index-level setting.
requests_per_secondnumberThe maximum number of documents to update per second, across the entire update_by_query operation (including slices). It can be either `-1` to turn off throttling or any decimal number like `1.7` or `12` to throttle to that level.
routingoneOfA custom value used to route operations to a specific shard.
scrolloneOfThe period to retain the search context for scrolling.
scroll_sizenumberThe size of the scroll request that powers the operation.
search_timeoutoneOfAn explicit timeout for each search request. By default, there is no timeout.
search_typestringThe type of the search operation. Available options include `query_then_fetch` and `dfs_query_then_fetch`.
One ofquery_then_fetchdfs_query_then_fetch
slicesoneOfThe number of slices this task should be divided into.
sortarray<string>A comma-separated list of <field>:<direction> pairs.
statsarray<string>The specific `tag` of the request for logging and statistical purposes.
terminate_afternumberThe 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.
timeoutoneOfThe 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.
versionbooleanIf `true`, returns the document version as part of a hit.
version_typebooleanShould the document increment the version number (internal) on hit or not (reindex)
wait_for_active_shardsoneOfThe 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`). The `timeout` 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.
wait_for_completionbooleanIf `true`, the request blocks until the operation is complete. If `false`, 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}`.
Request body
Enter the body as JSON in the step's Body field.
max_docsnumberThe maximum number of documents to update.
queryanyThe documents to update using the Query DSL.
scriptanyThe script to run to update the document source or metadata when updating.
sliceanySlice the request manually using the provided slice ID and total number of slices.
conflictsanyThe preferred behavior when update by query hits version conflicts: `abort` or `proceed`.
Default "abort"
{
"max_docs": 0,
"query": null,
"script": null,
"slice": null,
"conflicts": "abort"
}
Response
Returns 200 with an object. Read it in later steps with {{updateDocuments.response.data.<field>}}.
batchesnumberThe number of scroll responses pulled back by the update by query.
failuresarray<object>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.
causeanyrequiredidanyrequiredindexanyrequiredstatusnumberrequirednoopsnumberThe number of documents that were ignored because the script used for the update by query returned a noop value for `ctx.op`.
deletednumberThe number of documents that were successfully deleted.
requests_per_secondnumberThe number of requests per second effectively run during the update by query.
retriesanyThe number of retries attempted by update by query. `bulk` is the number of bulk actions retried. `search` is the number of search actions retried.
slicesarray<object>Status of each slice if the update by query was sliced
slice_idnumberThe slice ID
batchesnumberrequiredThe number of scroll responses pulled back by the reindex.
creatednumberThe number of documents that were successfully created.
deletednumberrequiredThe number of documents that were successfully deleted.
noopsnumberrequiredThe number of documents that were ignored because the script used for the reindex returned a `noop` value for `ctx.op`.
requests_per_secondnumberrequiredThe number of requests per second effectively executed during the reindex.
retriesanyrequiredThe number of retries attempted by reindex. `bulk` is the number of bulk actions retried and `search` is the number of search actions retried.
throttledanythrottled_millisanyrequiredNumber of milliseconds the request slept to conform to `requests_per_second`.
throttled_untilanythrottled_until_millisanyrequiredThis field should always be equal to zero in a `_reindex` response. It only has meaning when using the Task API, where it indicates the next time (in milliseconds since epoch) a throttled request will be executed again in order to conform to `requests_per_second`.
totalnumberrequiredThe number of documents that were successfully processed.
updatednumberThe number of documents that were successfully updated, for example, a document with same ID already existed prior to reindex updating it.
version_conflictsnumberrequiredThe number of version conflicts that reindex hits.
cancelledstringThe reason for cancellation if the slice was canceled
taskanytimed_outbooleanIf true, some requests timed out during the update by query.
tookanyThe number of milliseconds from start to end of the whole operation.
totalnumberThe number of documents that were successfully processed.
updatednumberThe number of documents that were successfully updated.
version_conflictsnumberThe number of version conflicts that the update by query hit.
throttledanythrottled_millisanyThe number of milliseconds the request slept to conform to `requests_per_second`.
throttled_untilanythrottled_until_millisanyThis field should always be equal to zero in an _update_by_query response. It only has meaning when using the task API, where it indicates the next time (in milliseconds since epoch) a throttled request will be run again in order to conform to `requests_per_second`.
{
"batches": 0,
"failures": [
{
"cause": null,
"id": null,
"index": null,
"status": 0
}
],
"noops": 0,
"deleted": 0,
"requests_per_second": 0,
"retries": null,
"slices": [
{
"batches": 0,
"deleted": 0,
"noops": 0,
"requests_per_second": 0,
"retries": null,
"throttled_millis": null,
"throttled_until_millis": null,
"total": 0,
"version_conflicts": 0,
"slice_id": 0,
"created": 0,
"throttled": null
}
],
"task": null,
"timed_out": false,
"took": null,
"total": 0,
"updated": 0
}
Need more? See the Elasticsearch guide for connection setup and behaviour shared by every action.