stack es delete-by-query cli command
elastic stack es delete-by-query --index <index> [options]
Delete documents.
Behaviour flags:
--dry-run — validate all inputs and exit without performing any action
--indexstringrequired-
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.Repeatable: pass
--indexmultiple times to supply more than one value --allow-no-indices- A setting that does two separate checks on the index expression.
If
false, the request returns an error (1) if any wildcard expression (including_alland*) 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. Iftrue, 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
qquery string parameter is specified. --analyze-wildcard- If
true, wildcard and prefix queries are analyzed. This parameter can be used only when theqquery string parameter is specified. --conflictsenum-
What to do if delete by query hits version conflicts:
abortorproceed.Values: abort, proceed
--default-operatorenum-
The default operator for query string query:
andoror. This parameter can be used only when theqquery string parameter is specified.Values: and, or
--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
qquery string parameter is specified. --expand-wildcardsenum-
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.Values: all, open, closed, hidden, none
Repeatable: pass
--expand-wildcardsmultiple times to supply more than one value --fromnumber- Skips the specified number of documents.
- 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. Iftrue, unavailable concrete targets are silently ignored. --lenient- 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 theqquery string parameter is specified. --max-docsnumber- The maximum number of documents to delete.
--preferencestring- The node or shard the operation should be performed on. It is random by default.
--refresh- If
true, Elasticsearch refreshes all shards involved in the delete by query after the request completes. This is different than the delete API'srefreshparameter, which causes just the shard that received the delete request to be refreshed. Unlike the delete API, it does not supportwait_for. --request-cache- 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
-1to turn off throttling or any decimal number like1.7or12to throttle to that level. --routingstring-
A custom value used to route operations to a specific shard. Not allowed when
index.slice.enabledistruefor the target index; use_sliceinstead.Repeatable: pass
--routingmultiple times to supply more than one value --qstring- A query in the Lucene query string syntax.
--scrollstring- The period to retain the search context for scrolling.
--scroll-sizenumber- The size of the scroll request that powers the operation.
--search-timeoutstring- The explicit timeout for each search request. It defaults to no timeout.
--search-typeenum-
The type of the search operation. Available options include
query_then_fetchanddfs_query_then_fetch.Values: query_then_fetch, dfs_query_then_fetch
--slicesstring- The number of slices this task should be divided into.
--sortstring-
A sort object that specifies the order of deleted documents.
Repeatable: pass
--sortmultiple times to supply more than one value --statsstring[]-
The specific
tagof the request for logging and statistical purposes.Repeatable: pass
--statsmultiple times to supply more than one value --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.
--timeoutstring- The period each deletion request waits for active shards.
--version- If
true, returns the document version as part of a hit. --wait-for-active-shardsstring- The number of shard copies that must be active before proceeding with the operation.
Set to
allor any positive integer up to the total number of shards in the index (number_of_replicas+1). Thetimeoutvalue controls how long each write request waits for unavailable shards to become available. --wait-for-completion- 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. --querystring- The documents to delete specified with Query DSL.
--slicestring- Slice the request manually using the provided slice ID and total number of slices.
--error-trace- When set to
trueElasticsearch will include the full stack trace of errors when they occur. --filter-pathstring-
Comma-separated list of filters in dot notation which reduce the response returned by Elasticsearch.
Repeatable: pass
--filter-pathmultiple times to supply more than one value --human- When set to
truewill return statistics in a format suitable for humans. For example"exists_time": "1h"for humans and"exists_time_in_millis": 3600000for computers. When disabled the human readable values will be omitted. This makes sense for responses being consumed only by machines. --pretty- If set to
truethe returned JSON will be "pretty-formatted". Only use this option for debugging only. --input-filestring- path to a JSON file to use as command input
--dry-run- validate all inputs and exit without performing any action (preview changes without applying them)
--json-
output as JSON