Commit a072133b92764d75cb78461de6602505467aa0a4
1 parent
b092101f
Exists in
master
and in
19 other branches
Removed retry_misspellings option [skip ci]
Showing
4 changed files
with
9 additions
and
17 deletions
Show diff stats
lib/searchkick.rb
... | ... | @@ -100,8 +100,8 @@ module Searchkick |
100 | 100 | end |
101 | 101 | end |
102 | 102 | |
103 | - def self.multi_search(queries, retry_misspellings: false) | |
104 | - Searchkick::MultiSearch.new(queries, retry_misspellings: retry_misspellings).perform | |
103 | + def self.multi_search(queries) | |
104 | + Searchkick::MultiSearch.new(queries).perform | |
105 | 105 | end |
106 | 106 | |
107 | 107 | # callbacks | ... | ... |
lib/searchkick/logging.rb
... | ... | @@ -129,7 +129,7 @@ module Searchkick |
129 | 129 | end |
130 | 130 | |
131 | 131 | module SearchkickWithInstrumentation |
132 | - def multi_search(searches, **options) | |
132 | + def multi_search(searches) | |
133 | 133 | event = { |
134 | 134 | name: "Multi Search", |
135 | 135 | body: searches.flat_map { |q| [q.params.except(:body).to_json, q.body.to_json] }.map { |v| "#{v}\n" }.join | ... | ... |
lib/searchkick/multi_search.rb
... | ... | @@ -2,25 +2,24 @@ module Searchkick |
2 | 2 | class MultiSearch |
3 | 3 | attr_reader :queries |
4 | 4 | |
5 | - def initialize(queries, retry_misspellings: false) | |
5 | + def initialize(queries) | |
6 | 6 | @queries = queries |
7 | - @retry_misspellings = retry_misspellings | |
8 | 7 | end |
9 | 8 | |
10 | 9 | def perform |
11 | 10 | if queries.any? |
12 | - perform_search(queries, retry_misspellings: @retry_misspellings) | |
11 | + perform_search(queries) | |
13 | 12 | end |
14 | 13 | end |
15 | 14 | |
16 | 15 | private |
17 | 16 | |
18 | - def perform_search(queries, retry_misspellings: true) | |
17 | + def perform_search(queries) | |
19 | 18 | responses = client.msearch(body: queries.flat_map { |q| [q.params.except(:body), q.body] })["responses"] |
20 | 19 | |
21 | 20 | retry_queries = [] |
22 | 21 | queries.each_with_index do |query, i| |
23 | - if retry_misspellings && query.retry_misspellings?(responses[i]) | |
22 | + if query.retry_misspellings?(responses[i]) | |
24 | 23 | query.send(:prepare) # okay, since we don't want to expose this method outside Searchkick |
25 | 24 | retry_queries << query |
26 | 25 | else |
... | ... | @@ -28,8 +27,8 @@ module Searchkick |
28 | 27 | end |
29 | 28 | end |
30 | 29 | |
31 | - if retry_misspellings && retry_queries.any? | |
32 | - perform_search(retry_queries, retry_misspellings: false) | |
30 | + if retry_queries.any? | |
31 | + perform_search(retry_queries) | |
33 | 32 | end |
34 | 33 | |
35 | 34 | queries | ... | ... |
test/multi_search_test.rb
... | ... | @@ -24,13 +24,6 @@ class MultiSearchTest < Minitest::Test |
24 | 24 | store_names ["abc", "abd", "aee"] |
25 | 25 | products = Product.search("abc", misspellings: {below: 2}, execute: false) |
26 | 26 | Searchkick.multi_search([products]) |
27 | - assert_equal ["abc"], products.map(&:name) | |
28 | - end | |
29 | - | |
30 | - def test_misspellings_below_unmet_retry | |
31 | - store_names ["abc", "abd", "aee"] | |
32 | - products = Product.search("abc", misspellings: {below: 2}, execute: false) | |
33 | - Searchkick.multi_search([products], retry_misspellings: true) | |
34 | 27 | assert_equal ["abc", "abd"], products.map(&:name) |
35 | 28 | end |
36 | 29 | ... | ... |