Commit 1bd814e825756a562631db740335d0b07e1e8a1b
1 parent
b9a903c0
Exists in
master
and in
21 other branches
Added search timeout to payload - cc @elguapo1611
Showing
3 changed files
with
15 additions
and
0 deletions
Show diff stats
CHANGELOG.md
lib/searchkick/query.rb
... | ... | @@ -368,6 +368,9 @@ module Searchkick |
368 | 368 | # highlight |
369 | 369 | set_highlights(payload, fields) if options[:highlight] |
370 | 370 | |
371 | + # timeout shortly after client times out | |
372 | + payload[:timeout] ||= "#{Searchkick.search_timeout + 1}s" | |
373 | + | |
371 | 374 | # An empty array will cause only the _id and _type for each hit to be returned |
372 | 375 | # doc for :select - http://www.elasticsearch.org/guide/reference/api/search/fields/ |
373 | 376 | # doc for :select_v2 - https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-source-filtering.html | ... | ... |
test/query_test.rb
... | ... | @@ -20,4 +20,12 @@ class QueryTest < Minitest::Test |
20 | 20 | store_names ["Milk", "Milk2"] |
21 | 21 | assert_equal ["Milk", "Milk2"], Product.search("Milk", body_options: { min_score: 0.0001 }).map(&:name) |
22 | 22 | end |
23 | + | |
24 | + def test_default_timeout | |
25 | + assert_equal "6s", Product.search("*", execute: false).body[:timeout] | |
26 | + end | |
27 | + | |
28 | + def test_timeout_override | |
29 | + assert_equal "1s", Product.search("*", body_options: {timeout: "1s"}, execute: false).body[:timeout] | |
30 | + end | |
23 | 31 | end | ... | ... |