module Elasticsearch::Model::Adapter::Mongoid::Importing
Public Instance Methods
__find_in_batches(options={}) { |items| ... }
click to toggle source
Fetch batches of records from the database
@see github.com/mongoid/mongoid/issues/1334 @see github.com/karmi/retire/pull/724
# File lib/elasticsearch/model/adapters/mongoid.rb, line 65 def __find_in_batches(options={}, &block) options[:batch_size] ||= 1_000 items = [] all.each do |item| items << item if items.length % options[:batch_size] == 0 yield items items = [] end end unless items.empty? yield items end end
__transform()
click to toggle source
# File lib/elasticsearch/model/adapters/mongoid.rb, line 83 def __transform lambda {|a| { index: { _id: a.id.to_s, data: a.as_indexed_json } }} end