younifyd
Menu

Update documents

Update documents

POST/{index}/_update_by_query

Use it in a workflow

  1. Add a step and choose the Elasticsearch connector.
  2. Pick the Update documents action (under document).
  3. Fill in the fields below, then reference the result from later steps as {{updateDocuments.response.data}}.

Request

Path parameters

indexoneOfrequired

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

allow_no_indicesboolean

A 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.

analyzerstring

The analyzer to use for the query string. This parameter can be used only when the `q` query string parameter is specified.

analyze_wildcardboolean

If `true`, wildcard and prefix queries are analyzed. This parameter can be used only when the `q` query string parameter is specified.

conflictsstring

The preferred behavior when update by query hits version conflicts: `abort` or `proceed`.

One ofabortproceed

default_operatorstring

The 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

dfstring

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.

expand_wildcardsoneOf

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`.

fromnumber

Skips the specified number of documents.

ignore_unavailableboolean

If `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.

lenientboolean

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 the `q` query string parameter is specified.

max_docsnumber

The 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.

pipelinestring

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.

preferencestring

The node or shard the operation should be performed on. It is random by default.

qstring

A query in the Lucene query string syntax.

refreshboolean

If `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_cacheboolean

If `true`, the request cache is used for this request. It defaults to the index-level setting.

requests_per_secondnumber

The 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.

routingoneOf

A custom value used to route operations to a specific shard.

scrolloneOf

The period to retain the search context for scrolling.

scroll_sizenumber

The size of the scroll request that powers the operation.

search_timeoutoneOf

An explicit timeout for each search request. By default, there is no timeout.

search_typestring

The type of the search operation. Available options include `query_then_fetch` and `dfs_query_then_fetch`.

One ofquery_then_fetchdfs_query_then_fetch

slicesoneOf

The 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_afternumber

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.

timeoutoneOf

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.

versionboolean

If `true`, returns the document version as part of a hit.

version_typeboolean

Should the document increment the version number (internal) on hit or not (reindex)

wait_for_active_shardsoneOf

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`). 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_completionboolean

If `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_docsnumber

The maximum number of documents to update.

queryany

The documents to update using the Query DSL.

scriptany

The script to run to update the document source or metadata when updating.

sliceany

Slice the request manually using the provided slice ID and total number of slices.

conflictsany

The preferred behavior when update by query hits version conflicts: `abort` or `proceed`.

Default "abort"

json
{
  "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>}}.

batchesnumber

The 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.

causeanyrequired
idanyrequired
indexanyrequired
statusnumberrequired
noopsnumber

The number of documents that were ignored because the script used for the update by query returned a noop value for `ctx.op`.

deletednumber

The number of documents that were successfully deleted.

requests_per_secondnumber

The number of requests per second effectively run during the update by query.

retriesany

The 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_idnumber

The slice ID

batchesnumberrequired

The number of scroll responses pulled back by the reindex.

creatednumber

The number of documents that were successfully created.

deletednumberrequired

The number of documents that were successfully deleted.

noopsnumberrequired

The number of documents that were ignored because the script used for the reindex returned a `noop` value for `ctx.op`.

requests_per_secondnumberrequired

The number of requests per second effectively executed during the reindex.

retriesanyrequired

The number of retries attempted by reindex. `bulk` is the number of bulk actions retried and `search` is the number of search actions retried.

throttledany
throttled_millisanyrequired

Number of milliseconds the request slept to conform to `requests_per_second`.

throttled_untilany
throttled_until_millisanyrequired

This 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`.

totalnumberrequired

The number of documents that were successfully processed.

updatednumber

The number of documents that were successfully updated, for example, a document with same ID already existed prior to reindex updating it.

version_conflictsnumberrequired

The number of version conflicts that reindex hits.

cancelledstring

The reason for cancellation if the slice was canceled

taskany
timed_outboolean

If true, some requests timed out during the update by query.

tookany

The number of milliseconds from start to end of the whole operation.

totalnumber

The number of documents that were successfully processed.

updatednumber

The number of documents that were successfully updated.

version_conflictsnumber

The number of version conflicts that the update by query hit.

throttledany
throttled_millisany

The number of milliseconds the request slept to conform to `requests_per_second`.

throttled_untilany
throttled_until_millisany

This 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`.

json
{
  "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.