Menu
Delete documents
Delete documents
/{index}/_delete_by_queryUse it in a workflow
- Add a step and choose the Elasticsearch connector.
- Pick the Delete documents action (under document).
- Fill in the fields below, then reference the result from later steps as
{{deleteDocuments.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.
analyzerstringAnalyzer 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.
conflictsstringWhat to do if delete 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. 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.
preferencestringThe node or shard the operation should be performed on. It is random by default.
refreshbooleanIf `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_cachebooleanIf `true`, the request cache is used for this request. Defaults to the index-level setting.
requests_per_secondnumberThe 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.
routingoneOfA custom value used to route operations to a specific shard.
qstringA query in the Lucene query string syntax.
scrolloneOfThe period to retain the search context for scrolling.
scroll_sizenumberThe size of the scroll request that powers the operation.
search_timeoutoneOfThe explicit timeout for each search request. It defaults to 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. 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 deletion request waits for active shards.
versionbooleanIf `true`, returns the document version as part of a hit.
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` value controls how long each write request waits for unavailable shards to become available.
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 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_docsnumberThe maximum number of documents to delete.
queryanyThe documents to delete specified with Query DSL.
sliceanySlice the request manually using the provided slice ID and total number of slices.
sortanyA sort object that specifies the order of deleted documents.
{
"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>}}.
batchesnumberThe number of scroll responses pulled back by the delete by query.
deletednumberThe 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.
causeanyrequiredidanyrequiredindexanyrequiredstatusnumberrequirednoopsnumberThis 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_secondnumberThe number of requests per second effectively run during the delete by query.
retriesanyThe 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_idnumberslicesarray<object>Status of each slice if the delete 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
taskanythrottledanythrottled_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 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_outbooleanIf `true`, some requests run during the delete by query operation timed out.
tookanyThe number of milliseconds from start to end of the whole operation.
totalnumberThe number of documents that were successfully processed.
version_conflictsnumberThe number of version conflicts that the delete by query hit.
{
"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.