Delete documents Added in 5.0.0
Deletes documents that match the specified query.
Path parameters
-
Comma-separated list of data streams, indices, and aliases to search. Supports wildcards (
*
). To search all data streams or indices, omit this parameter or use*
or_all
.
Query parameters
-
allow_no_indices boolean
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 string
Analyzer to use for the query string.
-
analyze_wildcard boolean
If
true
, wildcard and prefix queries are analyzed. -
conflicts string
What to do if delete by query hits version conflicts:
abort
orproceed
.Values are
abort
orproceed
. -
default_operator string
The default operator for query string query:
AND
orOR
.Values are
and
,AND
,or
, orOR
. -
df string
Field to use as default where no field prefix is given in the query string.
-
expand_wildcards string | array[string]
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. Supports comma-separated values, such as
open,hidden
. Valid values are:all
,open
,closed
,hidden
,none
. -
from number
Starting offset (default: 0)
-
lenient boolean
If
true
, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. -
max_docs number
Maximum number of documents to process. Defaults to all documents.
-
preference string
Specifies the node or shard the operation should be performed on. Random by default.
-
refresh boolean
If
true
, Elasticsearch refreshes all shards involved in the delete by query after the request completes. -
request_cache boolean
If
true
, the request cache is used for this request. Defaults to the index-level setting. -
requests_per_second number
The throttle for this request in sub-requests per second.
-
routing string
Custom value used to route operations to a specific shard.
-
q string
Query in the Lucene query string syntax.
-
scroll string
Period to retain the search context for scrolling.
-
scroll_size number
Size of the scroll request that powers the operation.
-
search_timeout string
Explicit timeout for each search request. Defaults to no timeout.
-
search_type string
The type of the search operation. Available options:
query_then_fetch
,dfs_query_then_fetch
.Values are
query_then_fetch
ordfs_query_then_fetch
. -
slices number | string
The number of slices this task should be divided into.
-
sort array[string]
A comma-separated list of
: pairs. -
stats array[string]
Specific
tag
of the request for logging and statistical purposes. -
terminate_after number
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.
-
timeout string
Period each deletion request waits for active shards.
-
version boolean
If
true
, returns the document version as part of a hit. -
wait_for_active_shards number | string
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
). -
wait_for_completion boolean
If
true
, the request blocks until the operation is complete.
Body Required
curl \
-X POST http://api.example.com/{index}/_delete_by_query \
-H "Content-Type: application/json" \
-d '{"max_docs":42.0,"query":{},"slice":{"field":"string","id":"string","max":42.0}}'