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

- old
+ new

@@ -19,11 +19,10 @@ module API module Actions # Returns number of documents matching a query. # # @option arguments [List] :index A comma-separated list of indices to restrict the results - # @option arguments [List] :type A comma-separated list of types to restrict the results # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) # @option arguments [Boolean] :ignore_throttled Whether specified concrete, expanded or aliased indices should be ignored when throttled # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) # @option arguments [Number] :min_score Include only documents with a specific `_score` value in the result @@ -37,62 +36,31 @@ # @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored # @option arguments [Number] :terminate_after The maximum count for each shard, upon reaching which the query execution will terminate early # @option arguments [Hash] :headers Custom HTTP headers # @option arguments [Hash] :body A query to restrict the results specified with the Query DSL (optional) # - # *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-count.html # - # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.17/search-count.html - # def count(arguments = {}) headers = arguments.delete(:headers) || {} + body = arguments.delete(:body) + arguments = arguments.clone _index = arguments.delete(:index) - _type = arguments.delete(:type) - - method = if arguments[:body] - Elasticsearch::API::HTTP_POST - else - Elasticsearch::API::HTTP_GET - end - - path = if _index && _type - "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_count" - elsif _index + method = Elasticsearch::API::HTTP_POST + path = if _index "#{Utils.__listify(_index)}/_count" else "_count" 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(:count, [ - :ignore_unavailable, - :ignore_throttled, - :allow_no_indices, - :expand_wildcards, - :min_score, - :preference, - :routing, - :q, - :analyzer, - :analyze_wildcard, - :default_operator, - :df, - :lenient, - :terminate_after - ].freeze) end end end