Module: Eson::More::All
- Defined in:
- lib/eson/more/all.rb
Defined Under Namespace
Modules: Functions
Constant Summary collapse
- DEFAULT_OPTS =
{:search_type => :scan, :scroll => "10m", :size => 50}
Instance Method Summary collapse
-
#all(opts) ⇒ Object
Retrieves all documents matching a given option set.
Instance Method Details
#all(opts) ⇒ Object
Retrieves all documents matching a given option set. Automatically handles scrolling.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/eson/more/all.rb', line 22 def all(opts) scroll_response = search(DEFAULT_OPTS.merge(opts)) scroll_id = scroll_response["_scroll_id"] if block_given? while scroll_id scroll_id, results = Functions.fetch_more_results(self, scroll_id) yield results end else docs = [] while scroll_id scroll_id, results = Functions.fetch_more_results(self, scroll_id) docs += results end docs end end |