Delete 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
. - 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. - What to do if delete 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
.
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. 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. - The node or shard the operation should be performed on. It is random by default.
- If
true
, Elasticsearch refreshes all shards involved in the delete by query after the request completes. This is different than the delete API'srefresh
parameter, which causes just the shard that received the delete request to be refreshed. Unlike the delete API, it does not supportwait_for
. - If
true
, the request cache is used for this request. 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.
- A query in the Lucene query string syntax.
- The period to retain the search context for scrolling.
- The size of the scroll request that powers the operation.
- The explicit timeout for each search request. It defaults to 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
<field>:<direction>
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.
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 deletion request waits for active shards.
- If
true
, returns the document version as part of a hit. - 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
value controls how long each write request waits for unavailable shards to become available. - If
true
, the request blocks until the operation is complete. Iffalse
, 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.
application/json
Body Required
- The maximum number of documents to delete.
- An Elasticsearch Query DSL (Domain Specific Language) object that defines a query.
External documentation - 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.
Responses
- 200 application/json
Hide response attributes Show response attributes object- The number of scroll responses pulled back by the delete by query.
- The number of documents that were successfully deleted.
- 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.
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. - 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.
- The number of requests per second effectively run during the delete by query.
- Hide retries attributes Show retries attributes object
* The number of bulk actions retried.
* The number of search actions retried. task string | number
- 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
- If
true
, some requests run during the delete by query operation timed out. - Time unit for milliseconds
- The number of documents that were successfully processed.
- The number of version conflicts that the delete by query hit.