lib/elasticsearch/api/actions/update_by_query.rb in elasticsearch-api-7.17.11 vs lib/elasticsearch/api/actions/update_by_query.rb in elasticsearch-api-8.0.0.pre1

- old
+ new

@@ -19,12 +19,11 @@ module API module Actions # Performs an update on every document in the index without changing the source, # for example to pick up a mapping change. # - # @option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices (*Required*) - # @option arguments [List] :type A comma-separated list of document types to search; leave empty to perform the operation on all types + # @option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices # @option arguments [String] :analyzer The analyzer to use for the query string # @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed (default: false) # @option arguments [String] :default_operator The default operator for query string query (AND or OR) (options: AND, OR) # @option arguments [String] :df The field to use as default where no field prefix is given in the query string # @option arguments [Number] :from Starting offset (default: 0) @@ -38,13 +37,15 @@ # @option arguments [String] :q Query in the Lucene query string syntax # @option arguments [List] :routing A comma-separated list of specific routing values # @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search # @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch) # @option arguments [Time] :search_timeout Explicit timeout for each search request. Defaults to no timeout. - # @option arguments [Number] :size Deprecated, please use `max_docs` instead # @option arguments [Number] :max_docs Maximum number of documents to process (default: all documents) # @option arguments [List] :sort A comma-separated list of <field>:<direction> pairs + # @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return + # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field + # @option arguments [List] :_source_includes A list of fields to extract and return from the _source field # @option arguments [Number] :terminate_after The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. # @option arguments [List] :stats Specific 'tag' of the request for logging and statistical purposes # @option arguments [Boolean] :version Specify whether to return document version as part of a hit # @option arguments [Boolean] :version_type Should the document increment the version number (internal) on hit or not (reindex) # @option arguments [Boolean] :request_cache Specify if request cache should be used for this request or not, defaults to index level setting @@ -56,75 +57,29 @@ # @option arguments [Number] :requests_per_second The throttle to set on this request in sub-requests per second. -1 means no throttle. # @option arguments [Number|string] :slices 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`. # @option arguments [Hash] :headers Custom HTTP headers # @option arguments [Hash] :body The search definition using the Query DSL # - # *Deprecation notice*: - # Specifying types in urls has been deprecated - # Deprecated since version 7.0.0 + # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html # - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.17/docs-update-by-query.html - # def update_by_query(arguments = {}) raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] headers = arguments.delete(:headers) || {} + body = arguments.delete(:body) + arguments = arguments.clone _index = arguments.delete(:index) - _type = arguments.delete(:type) - method = Elasticsearch::API::HTTP_POST - path = if _index && _type - "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_update_by_query" - else - "#{Utils.__listify(_index)}/_update_by_query" - end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + path = "#{Utils.__listify(_index)}/_update_by_query" + params = Utils.process_params(arguments) - body = arguments[:body] - perform_request(method, path, params, body, headers).body + Elasticsearch::API::Response.new( + perform_request(method, path, params, body, headers) + ) end - - # Register this action with its valid params when the module is loaded. - # - # @since 6.2.0 - ParamsRegistry.register(:update_by_query, [ - :analyzer, - :analyze_wildcard, - :default_operator, - :df, - :from, - :ignore_unavailable, - :allow_no_indices, - :conflicts, - :expand_wildcards, - :lenient, - :pipeline, - :preference, - :q, - :routing, - :scroll, - :search_type, - :search_timeout, - :size, - :max_docs, - :sort, - :terminate_after, - :stats, - :version, - :version_type, - :request_cache, - :refresh, - :timeout, - :wait_for_active_shards, - :scroll_size, - :wait_for_completion, - :requests_per_second, - :slices - ].freeze) end end end