Commit 1bc72e34098d80a8dc616b4f35bca38ed9dd5973
Committed by
Andrew Kane
1 parent
4264bf28
Exists in
master
and in
19 other branches
Allow operator to be a symbol or string (#996)
Showing
2 changed files
with
8 additions
and
1 deletions
Show diff stats
lib/searchkick/query.rb
... | ... | @@ -307,7 +307,7 @@ module Searchkick |
307 | 307 | exclude_field = field |
308 | 308 | |
309 | 309 | if field == "_all" || field.end_with?(".analyzed") |
310 | - shared_options[:cutoff_frequency] = 0.001 unless operator == "and" || misspellings == false | |
310 | + shared_options[:cutoff_frequency] = 0.001 unless operator.to_s == "and" || misspellings == false | |
311 | 311 | qs.concat [ |
312 | 312 | shared_options.merge(analyzer: "searchkick_search"), |
313 | 313 | shared_options.merge(analyzer: "searchkick_search2") | ... | ... |
test/match_test.rb
... | ... | @@ -18,6 +18,13 @@ class MatchTest < Minitest::Test |
18 | 18 | assert_search "pepperjack cheese skewers", ["Pepper Jack Cheese Skewers"] |
19 | 19 | end |
20 | 20 | |
21 | + def test_operator | |
22 | + store_names ["fresh", "honey"] | |
23 | + assert_search "fresh honey", ["fresh", "honey"], {operator: "or"} | |
24 | + assert_search "fresh honey", [], {operator: "and"} | |
25 | + assert_search "fresh honey", ["fresh", "honey"], {operator: :or} | |
26 | + end | |
27 | + | |
21 | 28 | # def test_cheese_space_in_query |
22 | 29 | # store_names ["Pepperjack Cheese Skewers"] |
23 | 30 | # assert_search "pepper jack cheese skewers", ["Pepperjack Cheese Skewers"] | ... | ... |