Module: ROM::Elasticsearch::ScrollMethods

Included in:
Dataset
Defined in:
lib/rom/elasticsearch/scroll_methods.rb

Overview

Dataset’s scoll methods

See Also:

Instance Method Summary collapse

Instance Method Details

#scroll(ttl) ⇒ Dataset

Return dataset with :scroll set

Parameters:

  • ttl (String)

Returns:



18
19
20
# File 'lib/rom/elasticsearch/scroll_methods.rb', line 18

def scroll(ttl)
  params(scroll: ttl)
end

#scroll_enumerator(client, response) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rom/elasticsearch/scroll_methods.rb', line 23

def scroll_enumerator(client, response)
  Enumerator.new do |yielder|
    loop do
      hits = response.fetch("hits").fetch("hits")
      break if hits.empty?

      hits.each { |result| yielder.yield(result) }

      response = client.scroll(
        scroll_id: response.fetch("_scroll_id"),
        scroll: params[:scroll]
      )
    end
  end
end