Commit 3f0a13528f95bf79852269f84a525825001f406b

Authored by Andrew Kane
1 parent 2efe5bb5

Ensure both fields matching is better than one field matching

Showing 2 changed files with 10 additions and 2 deletions   Show diff stats
lib/searchkick/search.rb
... ... @@ -43,10 +43,10 @@ module Searchkick
43 43 else
44 44 dis_max do
45 45 query do
46   - match fields, term, boost: 10, operator: operator, analyzer: "searchkick_search"
  46 + match fields, term, use_dis_max: false, boost: 10, operator: operator, analyzer: "searchkick_search"
47 47 end
48 48 query do
49   - match fields, term, boost: 10, operator: operator, analyzer: "searchkick_search2"
  49 + match fields, term, use_dis_max: false, boost: 10, operator: operator, analyzer: "searchkick_search2"
50 50 end
51 51 query do
52 52 match fields, term, use_dis_max: false, fuzziness: 1, max_expansions: 1, operator: operator, analyzer: "searchkick_search"
... ...
test/sql_test.rb
... ... @@ -92,6 +92,14 @@ class TestSql < Minitest::Unit::TestCase
92 92 assert_search "milk", [], fields: ["not_here"]
93 93 end
94 94  
  95 + def test_fields_both_match
  96 + store [
  97 + {name: "Blue A", color: "red"},
  98 + {name: "Blue B", color: "light blue"}
  99 + ]
  100 + assert_first "blue", "Blue B", fields: [:name, :color]
  101 + end
  102 +
95 103 # load
96 104  
97 105 def test_load_default
... ...