younifyd
Menu

Delete documents

Delete documents

POST/{index}/_delete_by_query

Use it in a workflow

  1. Add a step and choose the Elasticsearch connector.
  2. Pick the Delete documents action (under document).
  3. Fill in the fields below, then reference the result from later steps as {{deleteDocuments.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

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

What to do if delete 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. Defaults to all documents. When set to a value less then or equal to `scroll_size`, a scroll will not be used to retrieve the results for the operation.

preferencestring

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

refreshboolean

If `true`, Elasticsearch refreshes all shards involved in the delete by query after the request completes. This is different than the delete API's `refresh` parameter, which causes just the shard that received the delete request to be refreshed. Unlike the delete API, it does not support `wait_for`.

request_cacheboolean

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

requests_per_secondnumber

The maximum number of documents to delete per second, across the entire delete-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.

qstring

A query in the Lucene query string syntax.

scrolloneOf

The period to retain the search context for scrolling.

scroll_sizenumber

The size of the scroll request that powers the operation.

search_timeoutoneOf

The explicit timeout for each search request. It defaults to 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. 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 deletion request waits for active shards.

versionboolean

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

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` value controls how long each write request waits for unavailable shards to become available.

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 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}`. When you are done with a task, you should delete the task document so Elasticsearch can reclaim the space.

Request body

Enter the body as JSON in the step's Body field.

max_docsnumber

The maximum number of documents to delete.

queryany

The documents to delete specified with Query DSL.

sliceany

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

sortany

A sort object that specifies the order of deleted documents.

json
{
  "max_docs": 0,
  "query": null,
  "slice": null,
  "sort": null
}

Response

Returns 200 with an object. Read it in later steps with {{deleteDocuments.response.data.<field>}}.

batchesnumber

The number of scroll responses pulled back by the delete by query.

deletednumber

The number of documents that were successfully deleted.

failuresarray<object>

An array of failures if there were any unrecoverable errors during the process. If this array is not empty, the request ended abnormally because of those failures. Delete by query is implemented using batches and any failures cause 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 on version conflicts.

causeanyrequired
idanyrequired
indexanyrequired
statusnumberrequired
noopsnumber

This field is always equal to zero for delete by query. It exists only so that delete by query, update by query, and reindex APIs return responses with the same structure.

requests_per_secondnumber

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

retriesany

The number of retries attempted by delete by query. `bulk` is the number of bulk actions retried. `search` is the number of search actions retried.

slice_idnumber
slicesarray<object>

Status of each slice if the delete 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
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 a `_delete_by_query` response. It has meaning only 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`.

timed_outboolean

If `true`, some requests run during the delete by query operation timed out.

tookany

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

totalnumber

The number of documents that were successfully processed.

version_conflictsnumber

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

json
{
  "batches": 0,
  "deleted": 0,
  "failures": [
    {
      "cause": null,
      "id": null,
      "index": null,
      "status": 0
    }
  ],
  "noops": 0,
  "requests_per_second": 0,
  "retries": null,
  "slice_id": 0,
  "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,
  "throttled": null,
  "throttled_millis": null,
  "throttled_until": null
}

Need more? See the Elasticsearch guide for connection setup and behaviour shared by every action.