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

- old
+ new

@@ -19,11 +19,10 @@ module API module Actions # Returns results matching a query. # # @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 [List] :type A comma-separated list of document types to search; leave empty to perform the operation on all types # @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 [Boolean] :ccs_minimize_roundtrips Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution # @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 @@ -52,11 +51,11 @@ # @option arguments [String] :suggest_mode Specify suggest mode (options: missing, popular, always) # @option arguments [Number] :suggest_size How many suggestions to return in response # @option arguments [String] :suggest_text The source text for which the suggestions should be returned # @option arguments [Time] :timeout Explicit operation timeout # @option arguments [Boolean] :track_scores Whether to calculate and return scores even if they are not used for sorting - # @option arguments [Boolean] :track_total_hits Indicate if the number of documents that match the query should be tracked + # @option arguments [Boolean|long] :track_total_hits Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number. # @option arguments [Boolean] :allow_partial_search_results Indicate if an error should be returned if there is a partial search failure or timeout # @option arguments [Boolean] :typed_keys Specify whether aggregation and suggester names should be prefixed by their respective types in the response # @option arguments [Boolean] :version Specify whether to return document version as part of a hit # @option arguments [Boolean] :seq_no_primary_term Specify whether to return sequence number and primary term of the last modification of each hit # @option arguments [Boolean] :request_cache Specify if request cache should be used for this request or not, defaults to index level setting @@ -66,92 +65,37 @@ # @option arguments [Boolean] :rest_total_hits_as_int Indicates whether hits.total should be rendered as an integer or an object in the rest search response # @option arguments [String] :min_compatible_shard_node The minimum compatible version that all shards involved in search should have for this request to be successful # @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/search-search.html # - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.17/search-search.html - # def search(arguments = {}) headers = arguments.delete(:headers) || {} + body = arguments.delete(:body) + arguments = arguments.clone arguments[:index] = UNDERSCORE_ALL if !arguments[:index] && arguments[:type] _index = arguments.delete(:index) - _type = arguments.delete(:type) - - method = if arguments[:body] + method = if body Elasticsearch::API::HTTP_POST else Elasticsearch::API::HTTP_GET end - path = if _index && _type - "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_search" - elsif _index + path = if _index "#{Utils.__listify(_index)}/_search" else "_search" end - params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) + 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(:search, [ - :analyzer, - :analyze_wildcard, - :ccs_minimize_roundtrips, - :default_operator, - :df, - :explain, - :stored_fields, - :docvalue_fields, - :from, - :ignore_unavailable, - :ignore_throttled, - :allow_no_indices, - :expand_wildcards, - :lenient, - :preference, - :q, - :routing, - :scroll, - :search_type, - :size, - :sort, - :_source, - :_source_excludes, - :_source_includes, - :terminate_after, - :stats, - :suggest_field, - :suggest_mode, - :suggest_size, - :suggest_text, - :timeout, - :track_scores, - :track_total_hits, - :allow_partial_search_results, - :typed_keys, - :version, - :seq_no_primary_term, - :request_cache, - :batched_reduce_size, - :max_concurrent_shard_requests, - :pre_filter_shard_size, - :rest_total_hits_as_int, - :min_compatible_shard_node - ].freeze) end end end