Method: OpenSearch::API::Actions#delete_by_query
- Defined in:
- lib/opensearch/api/actions/delete_by_query.rb
#delete_by_query(arguments = {}) ⇒ Object
Deletes documents matching the provided query.
*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0
Parameters:
-
arguments
(Hash)
(defaults to: {})
—
a customizable set of options
Options Hash (arguments):
-
:index
(List)
—
A comma-separated list of index names to search; use
_allor empty string to perform the operation on all indices (Required) -
:analyzer
(String)
—
The analyzer to use for the query string
-
:analyze_wildcard
(Boolean)
—
Specify whether wildcard and prefix queries should be analyzed (default: false)
-
:default_operator
(String)
—
The default operator for query string query (AND or OR) (options: AND, OR)
-
:df
(String)
—
The field to use as default where no field prefix is given in the query string
-
:from
(Number)
—
Starting offset (default: 0)
-
:ignore_unavailable
(Boolean)
—
Whether specified concrete indices should be ignored when unavailable (missing or closed)
-
:allow_no_indices
(Boolean)
—
Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes
_allstring or when no indices have been specified) -
:conflicts
(String)
—
What to do when the delete by query hits version conflicts? (options: abort, proceed)
-
:expand_wildcards
(String)
—
Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
-
:lenient
(Boolean)
—
Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
-
:preference
(String)
—
Specify the node or shard the operation should be performed on (default: random)
-
:q
(String)
—
Query in the Lucene query string syntax
-
:routing
(List)
—
A comma-separated list of specific routing values
-
:scroll
(Time)
—
Specify how long a consistent view of the index should be maintained for scrolled search
-
:search_type
(String)
—
Search operation type (options: query_then_fetch, dfs_query_then_fetch)
-
:search_timeout
(Time)
—
Explicit timeout for each search request. Defaults to no timeout.
-
:size
(Number)
—
Deprecated, please use
max_docsinstead -
:max_docs
(Number)
—
Maximum number of documents to process (default: all documents)
-
:sort
(List)
—
A comma-separated list of <field>:<direction> pairs
-
:_source
(List)
—
True or false to return the _source field or not, or a list of fields to return
-
:_source_excludes
(List)
—
A list of fields to exclude from the returned _source field
-
:_source_includes
(List)
—
A list of fields to extract and return from the _source field
-
:terminate_after
(Number)
—
The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
-
:stats
(List)
—
Specific ‘tag’ of the request for logging and statistical purposes
-
:version
(Boolean)
—
Specify whether to return document version as part of a hit
-
:request_cache
(Boolean)
—
Specify if request cache should be used for this request or not, defaults to index level setting
-
:refresh
(Boolean)
—
Should the effected indexes be refreshed?
-
:timeout
(Time)
—
Time each individual bulk request should wait for shards that are unavailable.
-
:wait_for_active_shards
(String)
—
Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to
allfor all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) -
:scroll_size
(Number)
—
Size on the scroll request powering the delete by query
-
:wait_for_completion
(Boolean)
—
Should the request should block until the delete by query is complete.
-
:requests_per_second
(Number)
—
The throttle for this request in sub-requests per second. -1 means no throttle.
-
:slices
(Number|string)
—
The number of slices this task should be divided into. Defaults to 1, meaning the task isn’t sliced into subtasks. Can be set to
auto. -
:headers
(Hash)
—
Custom HTTP headers
-
:body
(Hash)
—
The search definition using the Query DSL (Required)
Raises:
- (ArgumentError)
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/opensearch/api/actions/delete_by_query.rb', line 75 def delete_by_query(arguments = {}) raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] headers = arguments.delete(:headers) || {} arguments = arguments.clone _index = arguments.delete(:index) method = OpenSearch::API::HTTP_POST path = "#{Utils.__listify(_index)}/_delete_by_query" params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) body = arguments[:body] perform_request(method, path, params, body, headers).body end |