Skip to content

Commit

Permalink
Add pipeline to bulk params
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelly Joseph Price authored and picandocodigo committed Mar 4, 2020
1 parent 1c34f6c commit 63c24c9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions elasticsearch-model/lib/elasticsearch/model/importing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def import(options={}, &block)
target_index = options.delete(:index) || index_name
target_type = options.delete(:type) || document_type
transform = options.delete(:transform) || __transform
pipeline = options.delete(:pipeline)
return_value = options.delete(:return) || 'count'

unless transform.respond_to?(:call)
Expand All @@ -158,10 +159,15 @@ def import(options={}, &block)
end

__find_in_batches(options) do |batch|
response = client.bulk \
index: target_index,
type: target_type,
body: __batch_to_bulk(batch, transform)
params = {
index: target_index,
type: target_type,
body: __batch_to_bulk(batch, transform)
}

params[:pipeline] = pipeline if pipeline

response = client.bulk params

yield response if block_given?

Expand Down

0 comments on commit 63c24c9

Please sign in to comment.