182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
# File 'lib/searchkick/results.rb', line 182
def scroll
raise Error, "Pass `scroll` option to the search method for scrolling" unless scroll_id
if block_given?
records = self
while records.any?
yield records
records = records.scroll
end
records.clear_scroll
else
begin
Results.new(@klass, Searchkick.client.scroll(scroll: options[:scroll], body: {scroll_id: scroll_id}), @options)
rescue => e
if Searchkick.not_found_error?(e) && e.message =~ /search_context_missing_exception/i
raise Error, "Scroll id has expired"
else
raise e
end
end
end
end
|