module ElasticRecord::Relation::Batches

Public Instance Methods

build_scroll_enumerator(options) click to toggle source
# File lib/elastic_record/relation/batches.rb, line 28
def build_scroll_enumerator(options)
  elastic_index.build_scroll_enumerator(search: as_elastic, **options)
end
find_each(options = {}) { |record| ... } click to toggle source
# File lib/elastic_record/relation/batches.rb, line 4
def find_each(options = {})
  find_in_batches(options) do |records|
    records.each { |record| yield record }
  end
end
find_hits_in_batches(options = {}) { |search_hits| ... } click to toggle source
# File lib/elastic_record/relation/batches.rb, line 22
def find_hits_in_batches(options = {})
  build_scroll_enumerator(options).each_slice do |hits|
    yield SearchHits.new(hits)
  end
end
find_ids_in_batches(options = {}) { |to_ids| ... } click to toggle source
# File lib/elastic_record/relation/batches.rb, line 16
def find_ids_in_batches(options = {})
  find_hits_in_batches(options) do |hits|
    yield hits.to_ids
  end
end
find_in_batches(options = {}) { |find_hits(hits)| ... } click to toggle source
# File lib/elastic_record/relation/batches.rb, line 10
def find_in_batches(options = {})
  find_hits_in_batches(options) do |hits|
    yield find_hits(hits)
  end
end
reindex() click to toggle source
# File lib/elastic_record/relation/batches.rb, line 32
def reindex
  relation.find_in_batches do |batch|
    elastic_index.bulk_add(batch)
  end
end