lib/elasticsearch/api/actions/search_template.rb in elasticsearch-api-8.10.0 vs lib/elasticsearch/api/actions/search_template.rb in elasticsearch-api-8.11.0

- old
+ new

@@ -38,13 +38,21 @@ # @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.10/search-template.html + # @see https://www.elastic.co/guide/en/elasticsearch/reference/8.11/search-template.html # def search_template(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || "search_template" } + + defined_params = [:index].inject({}) do |set_variables, variable| + 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] arguments = arguments.clone headers = arguments.delete(:headers) || {} @@ -59,10 +67,10 @@ "_search/template" end params = Utils.process_params(arguments) Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers) + perform_request(method, path, params, body, headers, request_opts) ) end end end end