Module: ElasticRecord::Relation::Batches
- Included in:
- ElasticRecord::Relation
- Defined in:
- lib/elastic_record/relation/batches.rb
Instance Method Summary collapse
- #build_scroll_enumerator(options) ⇒ Object
- #find_each(options = {}) ⇒ Object
- #find_hits_in_batches(options = {}) ⇒ Object
- #find_ids_in_batches(options = {}) ⇒ Object
- #find_in_batches(options = {}) ⇒ Object
- #reindex ⇒ Object
Instance Method Details
#build_scroll_enumerator(options) ⇒ Object
28 29 30 |
# File 'lib/elastic_record/relation/batches.rb', line 28 def build_scroll_enumerator() elastic_index.build_scroll_enumerator(search: as_elastic, **) end |
#find_each(options = {}) ⇒ Object
4 5 6 7 8 |
# File 'lib/elastic_record/relation/batches.rb', line 4 def find_each( = {}) find_in_batches() do |records| records.each { |record| yield record } end end |
#find_hits_in_batches(options = {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/elastic_record/relation/batches.rb', line 22 def find_hits_in_batches( = {}) build_scroll_enumerator().each_slice do |hits| yield SearchHits.new(hits) end end |
#find_ids_in_batches(options = {}) ⇒ Object
16 17 18 19 20 |
# File 'lib/elastic_record/relation/batches.rb', line 16 def find_ids_in_batches( = {}) find_hits_in_batches() do |hits| yield hits.to_ids end end |
#find_in_batches(options = {}) ⇒ Object
10 11 12 13 14 |
# File 'lib/elastic_record/relation/batches.rb', line 10 def find_in_batches( = {}) find_hits_in_batches() do |hits| yield find_hits(hits) end end |
#reindex ⇒ Object
32 33 34 35 36 |
# File 'lib/elastic_record/relation/batches.rb', line 32 def reindex relation.find_in_batches do |batch| elastic_index.bulk_add(batch) end end |