Commit c30567959cff1971f79ecc9886dafa290e64a452

Authored by Andrew
1 parent 6b2d34f5

Fixed field misspellings for older partial match format - #1194

CHANGELOG.md
... ... @@ -4,6 +4,7 @@
4 4 - Fixed deletes with routing and `async` callbacks
5 5 - Fixed deletes with routing and `queue` callbacks
6 6 - Fixed deprecation warnings
  7 +- Fixed field misspellings for older partial match format
7 8  
8 9 ## 3.1.1
9 10  
... ...
lib/searchkick/query.rb
... ... @@ -281,7 +281,7 @@ module Searchkick
281 281 prefix_length = (misspellings.is_a?(Hash) && misspellings[:prefix_length]) || 0
282 282 default_max_expansions = @misspellings_below ? 20 : 3
283 283 max_expansions = (misspellings.is_a?(Hash) && misspellings[:max_expansions]) || default_max_expansions
284   - misspellings_fields = misspellings.is_a?(Hash) && misspellings.key?(:fields) && misspellings[:fields].map { |f| "#{f}.#{@match_suffix}" }
  284 + misspellings_fields = misspellings.is_a?(Hash) && misspellings.key?(:fields) && misspellings[:fields].map { |f| f.is_a?(Hash) ? f.to_a.join(".") : "#{f}.#{@match_suffix}" }
285 285  
286 286 if misspellings_fields
287 287 missing_fields = misspellings_fields - fields
... ...
test/misspellings_test.rb
... ... @@ -97,4 +97,9 @@ class MisspellingsTest < Minitest::Test
97 97 assert_search "siracha", ["Sriracha"], {misspellings: {fields: [:name]}}
98 98 end
99 99 end
  100 +
  101 + def test_misspellings_field_word_start
  102 + store_names ["Sriracha"]
  103 + assert_search "siracha", ["Sriracha"], fields: [{name: :word_middle}], misspellings: {fields: [{name: :word_middle}]}
  104 + end
100 105 end
... ...