diff --git a/lib/chewy/type/import.rb b/lib/chewy/type/import.rb index 53b5d44fa..7a369fed2 100644 --- a/lib/chewy/type/import.rb +++ b/lib/chewy/type/import.rb @@ -76,10 +76,10 @@ def bulk options = {} private def bulk_body(action_objects, indexed_objects = nil) - action_objects.inject([]) do |result, (action, objects)| + action_objects.flat_map do |action, objects| method = "#{action}_bulk_entry" crutches = Chewy::Type::Crutch::Crutches.new self, objects - result.concat(objects.map { |object| send(method, object, indexed_objects, crutches) }.flatten) + objects.flat_map { |object| send(method, object, indexed_objects, crutches) } end end