lib/elasticsearch/api/actions/search_template.rb in elasticsearch-api-8.12.2 vs lib/elasticsearch/api/actions/search_template.rb in elasticsearch-api-8.13.0
- old
+ new
@@ -38,18 +38,17 @@
# @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*)
#
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-template.html
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/8.13/search-template.html
#
def search_template(arguments = {})
- request_opts = { endpoint: arguments[:endpoint] || "search_template" }
+ request_opts = { endpoint: arguments[:endpoint] || 'search_template' }
- defined_params = [:index].inject({}) do |set_variables, variable|
+ defined_params = [:index].each_with_object({}) do |variable, set_variables|
set_variables[variable] = arguments[variable] if arguments.key?(variable)
- set_variables
end
request_opts[:defined_params] = defined_params unless defined_params.empty?
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
@@ -62,10 +61,10 @@
method = Elasticsearch::API::HTTP_POST
path = if _index
"#{Utils.__listify(_index)}/_search/template"
else
- "_search/template"
+ '_search/template'
end
params = Utils.process_params(arguments)
Elasticsearch::API::Response.new(
perform_request(method, path, params, body, headers, request_opts)