diff --git a/CHANGELOG.md b/CHANGELOG.md index 57c6862..f2ebcb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## 5.1.0 (unreleased) +- Added support for fractional search timeout - Fixed search timeout with `elasticsearch` 8+ and `opensearch-ruby` gems - Fixed search timeout not applying to `multi_search` diff --git a/lib/searchkick/query.rb b/lib/searchkick/query.rb index a195e73..1f7567a 100644 --- a/lib/searchkick/query.rb +++ b/lib/searchkick/query.rb @@ -505,7 +505,13 @@ module Searchkick set_highlights(payload, fields) if options[:highlight] # timeout shortly after client times out - payload[:timeout] ||= "#{Searchkick.search_timeout + 1}s" + payload[:timeout] ||= + if Searchkick.search_timeout.is_a?(Integer) + "#{Searchkick.search_timeout + 1}s" + else + # ensure at least 1 ms + "#{(Searchkick.search_timeout * 1000).ceil}ms" + end # An empty array will cause only the _id and _type for each hit to be returned # https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-source-filtering.html -- libgit2 0.21.0