Commit 0022afc911229f0ba03b219ee1da2f297618870e
1 parent
695021af
Exists in
master
and in
19 other branches
Fixed tests for ES 2
Showing
2 changed files
with
10 additions
and
3 deletions
Show diff stats
lib/searchkick/query.rb
... | ... | @@ -335,6 +335,11 @@ module Searchkick |
335 | 335 | |
336 | 336 | if field.start_with?("*.") |
337 | 337 | q2 = qs.map { |q| {multi_match: q.merge(fields: [field], type: match_type == :match_phrase ? "phrase" : "best_fields")} } |
338 | + if below60? | |
339 | + q2.each do |q| | |
340 | + q[:multi_match].delete(:fuzzy_transpositions) | |
341 | + end | |
342 | + end | |
338 | 343 | else |
339 | 344 | q2 = qs.map { |q| {match_type => {field => q}} } |
340 | 345 | end |
... | ... | @@ -547,6 +552,8 @@ module Searchkick |
547 | 552 | ["_all.phrase"] |
548 | 553 | elsif term == "*" |
549 | 554 | [] |
555 | + elsif default_match == :exact | |
556 | + raise ArgumentError, "Must specify fields to search" | |
550 | 557 | else |
551 | 558 | [default_match == :word ? "*.analyzed" : "*.#{default_match}"] |
552 | 559 | end | ... | ... |
test/match_test.rb
... | ... | @@ -180,12 +180,12 @@ class MatchTest < Minitest::Test |
180 | 180 | |
181 | 181 | def test_exclude_butter_exact |
182 | 182 | store_names ["Butter Tub", "Peanut Butter Tub"] |
183 | - assert_search "butter", [], exclude: ["peanut butter"], match: :exact | |
183 | + assert_search "butter", [], exclude: ["peanut butter"], fields: [{name: :exact}] | |
184 | 184 | end |
185 | 185 | |
186 | 186 | def test_exclude_same_exact |
187 | 187 | store_names ["Butter Tub", "Peanut Butter Tub"] |
188 | - assert_search "Butter Tub", [], exclude: ["Butter Tub"], match: :exact | |
188 | + assert_search "Butter Tub", ["Butter Tub"], exclude: ["Peanut Butter Tub"], fields: [{name: :exact}] | |
189 | 189 | end |
190 | 190 | |
191 | 191 | def test_exclude_egg_word_start |
... | ... | @@ -242,7 +242,7 @@ class MatchTest < Minitest::Test |
242 | 242 | |
243 | 243 | def test_phrase |
244 | 244 | store_names ["Fresh Honey", "Honey Fresh"] |
245 | - assert_search "fresh honey", ["Fresh Honey"], match: :phrase | |
245 | + assert_search "fresh honey", ["Fresh Honey"], match: :phrase, fields: [:name] | |
246 | 246 | end |
247 | 247 | |
248 | 248 | def test_phrase_again | ... | ... |