lib/elasticsearch/api/actions/bulk.rb in elasticsearch-api-7.6.0 vs lib/elasticsearch/api/actions/bulk.rb in elasticsearch-api-7.7.0.pre

- old
+ new

@@ -18,18 +18,20 @@ # @option arguments [String] :type Default document type for items which don't provide one # @option arguments [List] :_source True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request # @option arguments [List] :_source_excludes Default list of fields to exclude from the returned _source field, can be overridden on each sub-request # @option arguments [List] :_source_includes Default list of fields to extract and return from the _source field, can be overridden on each sub-request # @option arguments [String] :pipeline The pipeline id to preprocess incoming documents with - + # @option arguments [Hash] :headers Custom HTTP headers # @option arguments [Hash] :body The operation definition and data (action-data pairs), separated by newlines (*Required*) # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-bulk.html + # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html # def bulk(arguments = {}) raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] + headers = arguments.delete(:headers) || {} + arguments = arguments.clone _index = arguments.delete(:index) _type = arguments.delete(:type) @@ -49,10 +51,11 @@ payload = Elasticsearch::API::Utils.__bulkify(body) else payload = body end - perform_request(method, path, params, payload, { "Content-Type" => "application/x-ndjson" }).body + headers.merge!("Content-Type" => "application/x-ndjson") + perform_request(method, path, params, payload, headers).body end # Register this action with its valid params when the module is loaded. # # @since 6.2.0