class Supple::Importer

Public Class Methods

new(scope, index_name, document_type) click to toggle source
# File lib/supple/model.rb, line 10
def initialize(scope, index_name, document_type)
  @scope = scope
  @index_name = index_name
  @document_type = document_type
end

Public Instance Methods

execute!() click to toggle source
# File lib/supple/model.rb, line 16
def execute!
  @scope.find_in_batches do |batch|
    Supple.client.bulk({
      index: @index_name,
      type: @document_type,
      body: transform_batch(batch)
    })
  end
end

Protected Instance Methods

transform_batch(batch) click to toggle source
# File lib/supple/model.rb, line 28
def transform_batch(batch)
   batch.map { |a| { index: { _id: a.id, data: a.as_indexed_json } } }
end