module Elasticsearch::Model::Adapter::JsonApiResource::Importing

Public Instance Methods

__find_in_batches(options={}) { |objects| ... } click to toggle source

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

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

# File lib/elasticsearch/model/adapter/json_api_resource.rb, line 49
def __find_in_batches(options={}, &block)
  page = 1
  loop do
    objects = where page: page, per_page: 100
    
    yield objects

    page +=1

    break if page >= objects.meta[:total_pages]

  end
end
__transform() click to toggle source
# File lib/elasticsearch/model/adapter/json_api_resource.rb, line 63
def __transform
  lambda { |model|  { index: { _id: model.id, data: model.__elasticsearch__.as_indexed_json } } }
end