Module: Elasticsearch::Model::Adapter::Mongoid::Importing

Defined in:
lib/elasticsearch/model/adapters/mongoid.rb

Instance Method Summary collapse

Instance Method Details

#__find_in_batches(options = {}, &block) ⇒ Object

Fetch batches of records from the database



65
66
67
68
69
70
71
# File 'lib/elasticsearch/model/adapters/mongoid.rb', line 65

def __find_in_batches(options={}, &block)
  options[:batch_size] ||= 1_000
  
  all.no_timeout.each_slice(options[:batch_size]) do |items|
    yield items
  end
end

#__transformObject



73
74
75
# File 'lib/elasticsearch/model/adapters/mongoid.rb', line 73

def __transform
  lambda {|a|  { index: { _id: a.id.to_s, data: a.as_indexed_json } }}
end