Commit 5a387e9f5a4d278641cce23ff3e996f07792a753
1 parent
75fae6a5
Exists in
master
Fixed search timeout not applying to multi_search - #1593
Showing
2 changed files
with
7 additions
and
1 deletions
Show diff stats
CHANGELOG.md
lib/searchkick/middleware.rb
... | ... | @@ -3,8 +3,13 @@ require "faraday" |
3 | 3 | module Searchkick |
4 | 4 | class Middleware < Faraday::Middleware |
5 | 5 | def call(env) |
6 | - if env[:url].path.to_s.end_with?("/_search") | |
6 | + path = env[:url].path.to_s | |
7 | + if path.end_with?("/_search") | |
7 | 8 | env[:request][:timeout] = Searchkick.search_timeout |
9 | + elsif path.end_with?("/_msearch") | |
10 | + # assume no concurrent searches for timeout for now | |
11 | + searches = env[:request_body].count("\n") / 2 | |
12 | + env[:request][:timeout] = Searchkick.search_timeout * searches | |
8 | 13 | end |
9 | 14 | @app.call(env) |
10 | 15 | end | ... | ... |