Commit 295f43baa5842f0e3c0da56e38f00759f7f066b3

Authored by Andrew Kane
1 parent 2bf4f242

Added clear_scroll method

Showing 2 changed files with 13 additions and 8 deletions   Show diff stats
CHANGELOG.md
1 1 ## 4.0.2 [unreleased]
2 2  
3 3 - Added block form of `scroll`
  4 +- Added `clear_scroll` method
4 5 - Fixed custom mappings
5 6  
6 7 ## 4.0.1
... ...
lib/searchkick/results.rb
... ... @@ -235,14 +235,7 @@ module Searchkick
235 235 records = records.scroll
236 236 end
237 237  
238   - begin
239   - # try to clear scroll
240   - # not required as scroll will expire
241   - # but there is a cost to open scrolls
242   - Searchkick.client.clear_scroll(scroll_id: scroll_id)
243   - rescue Elasticsearch::Transport::Transport::Error
244   - # okay if it fails
245   - end
  238 + records.clear_scroll
246 239 else
247 240 params = {
248 241 scroll: options[:scroll],
... ... @@ -262,6 +255,17 @@ module Searchkick
262 255 end
263 256 end
264 257  
  258 + def clear_scroll
  259 + begin
  260 + # try to clear scroll
  261 + # not required as scroll will expire
  262 + # but there is a cost to open scrolls
  263 + Searchkick.client.clear_scroll(scroll_id: scroll_id)
  264 + rescue Elasticsearch::Transport::Transport::Error
  265 + # do nothing
  266 + end
  267 + end
  268 +
265 269 private
266 270  
267 271 def results_query(records, hits)
... ...