Commit b94bf86ba66320df4cda790d7ac84a54da097032

Authored by Andrew Kane
1 parent 5a387e9f
Exists in master

Added support for fractional search timeout - #1593

Showing 2 changed files with 8 additions and 1 deletions   Show diff stats
CHANGELOG.md
1 1 ## 5.1.0 (unreleased)
2 2  
  3 +- Added support for fractional search timeout
3 4 - Fixed search timeout with `elasticsearch` 8+ and `opensearch-ruby` gems
4 5 - Fixed search timeout not applying to `multi_search`
5 6  
... ...
lib/searchkick/query.rb
... ... @@ -505,7 +505,13 @@ module Searchkick
505 505 set_highlights(payload, fields) if options[:highlight]
506 506  
507 507 # timeout shortly after client times out
508   - payload[:timeout] ||= "#{Searchkick.search_timeout + 1}s"
  508 + payload[:timeout] ||=
  509 + if Searchkick.search_timeout.is_a?(Integer)
  510 + "#{Searchkick.search_timeout + 1}s"
  511 + else
  512 + # ensure at least 1 ms
  513 + "#{(Searchkick.search_timeout * 1000).ceil}ms"
  514 + end
509 515  
510 516 # An empty array will cause only the _id and _type for each hit to be returned
511 517 # https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-source-filtering.html
... ...