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

- old
+ new

@@ -36,13 +36,21 @@ # @option arguments [Boolean] :require_alias Sets require_alias for all incoming documents. Defaults to unset (false) # @option arguments [Hash] :headers Custom HTTP headers # @option arguments [String|Array] :body The operation definition and data (action-data pairs), separated by newlines. Array of Strings, Header/Data pairs, # or the conveniency "combined" format can be passed, refer to Elasticsearch::API::Utils.__bulkify documentation. # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/8.10/docs-bulk.html + # @see https://www.elastic.co/guide/en/elasticsearch/reference/8.11/docs-bulk.html # def bulk(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || "bulk" } + + 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) || {} @@ -64,10 +72,10 @@ payload = body end headers.merge!("Content-Type" => "application/x-ndjson") Elasticsearch::API::Response.new( - perform_request(method, path, params, payload, headers) + perform_request(method, path, params, payload, headers, request_opts) ) end end end end