module Elasticsearch::Model::Adapter::ActiveRecord::Importing

Public Instance Methods

__find_in_batches(options={}) { |preprocess ? __send__: batch| ... } click to toggle source

Fetch batches of records from the database (used by the import method)

@see api.rubyonrails.org/classes/ActiveRecord/Batches.html ActiveRecord::Batches.find_in_batches

# File lib/elasticsearch/model/adapters/active_record.rb, line 86
def __find_in_batches(options={}, &block)
  named_scope = options.delete(:scope)
  preprocess = options.delete(:preprocess)

  scope = named_scope ? self.__send__(named_scope) : self

  scope.find_in_batches(options) do |batch|
    yield (preprocess ? self.__send__(preprocess, batch) : batch)
  end
end
__transform() click to toggle source
# File lib/elasticsearch/model/adapters/active_record.rb, line 97
def __transform
  lambda { |model|  { index: { _id: model.id, data: model.__elasticsearch__.as_indexed_json } } }
end