Commit 295f43baa5842f0e3c0da56e38f00759f7f066b3
1 parent
2bf4f242
Exists in
master
and in
17 other branches
Added clear_scroll method
Showing
2 changed files
with
13 additions
and
8 deletions
Show diff stats
CHANGELOG.md
lib/searchkick/results.rb
@@ -235,14 +235,7 @@ module Searchkick | @@ -235,14 +235,7 @@ module Searchkick | ||
235 | records = records.scroll | 235 | records = records.scroll |
236 | end | 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 | else | 239 | else |
247 | params = { | 240 | params = { |
248 | scroll: options[:scroll], | 241 | scroll: options[:scroll], |
@@ -262,6 +255,17 @@ module Searchkick | @@ -262,6 +255,17 @@ module Searchkick | ||
262 | end | 255 | end |
263 | end | 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 | private | 269 | private |
266 | 270 | ||
267 | def results_query(records, hits) | 271 | def results_query(records, hits) |