lib/elasticsearch/api/actions/search_template.rb in elasticsearch-api-7.17.11 vs lib/elasticsearch/api/actions/search_template.rb in elasticsearch-api-8.0.0.pre1
- old
+ new
@@ -19,11 +19,10 @@
module API
module Actions
# Allows to use the Mustache language to pre-render a search definition.
#
# @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 [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 [String] :preference Specify the node or shard the operation should be performed on (default: random)
@@ -36,58 +35,33 @@
# @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 [Boolean] :ccs_minimize_roundtrips Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
# @option arguments [Hash] :headers Custom HTTP headers
# @option arguments [Hash] :body The search definition template and its params (*Required*)
#
- # *Deprecation notice*:
- # Specifying types in urls has been deprecated
- # Deprecated since version 7.0.0
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html
#
- #
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.17/search-template.html
- #
def search_template(arguments = {})
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
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)}/_search/template"
- elsif _index
+ path = if _index
"#{Utils.__listify(_index)}/_search/template"
else
"_search/template"
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_template, [
- :ignore_unavailable,
- :ignore_throttled,
- :allow_no_indices,
- :expand_wildcards,
- :preference,
- :routing,
- :scroll,
- :search_type,
- :explain,
- :profile,
- :typed_keys,
- :rest_total_hits_as_int,
- :ccs_minimize_roundtrips
- ].freeze)
end
end
end