Commit 0395b35ef6b9f49e303cd05b488b366bdcc12c8e
1 parent
d482aec1
Exists in
master
and in
21 other branches
Added timeout method
Showing
3 changed files
with
17 additions
and
1 deletions
Show diff stats
CHANGELOG.md
README.md
... | ... | @@ -809,6 +809,12 @@ Product.enable_search_callbacks # or use Searchkick.enable_callbacks for all mod |
809 | 809 | Product.reindex |
810 | 810 | ``` |
811 | 811 | |
812 | +Change timeout [master] | |
813 | + | |
814 | +```ruby | |
815 | +Searchkick.timeout = 5 # defaults to 10 | |
816 | +``` | |
817 | + | |
812 | 818 | Change the search method name in `config/initializers/searchkick.rb` |
813 | 819 | |
814 | 820 | ```ruby | ... | ... |
lib/searchkick.rb
... | ... | @@ -21,13 +21,19 @@ module Searchkick |
21 | 21 | attr_accessor :callbacks |
22 | 22 | attr_accessor :search_method_name |
23 | 23 | attr_accessor :wordnet_path |
24 | + attr_accessor :timeout | |
24 | 25 | end |
25 | 26 | self.callbacks = true |
26 | 27 | self.search_method_name = :search |
27 | 28 | self.wordnet_path = "/var/lib/wn_s.pl" |
29 | + self.timeout = 10 | |
28 | 30 | |
29 | 31 | def self.client |
30 | - @client ||= Elasticsearch::Client.new(url: ENV["ELASTICSEARCH_URL"]) | |
32 | + @client ||= | |
33 | + Elasticsearch::Client.new( | |
34 | + url: ENV["ELASTICSEARCH_URL"], | |
35 | + transport_options: {request: {timeout: timeout}} | |
36 | + ) | |
31 | 37 | end |
32 | 38 | |
33 | 39 | def self.client=(client) | ... | ... |