Commit 1cc40079b58308730f684fa51cbf08779b59848b
1 parent
1fb35cc0
Exists in
master
and in
19 other branches
No longer require synonyms to be lowercase - #912
Showing
4 changed files
with
8 additions
and
1 deletions
Show diff stats
CHANGELOG.md
lib/searchkick/index_options.rb
@@ -167,7 +167,7 @@ module Searchkick | @@ -167,7 +167,7 @@ module Searchkick | ||
167 | if synonyms.any? | 167 | if synonyms.any? |
168 | settings[:analysis][:filter][:searchkick_synonym] = { | 168 | settings[:analysis][:filter][:searchkick_synonym] = { |
169 | type: "synonym", | 169 | type: "synonym", |
170 | - synonyms: synonyms.select { |s| s.size > 1 }.map { |s| s.is_a?(Array) ? s.join(",") : s } | 170 | + synonyms: synonyms.select { |s| s.size > 1 }.map { |s| s.is_a?(Array) ? s.join(",") : s }.map(&:downcase) |
171 | } | 171 | } |
172 | # choosing a place for the synonym filter when stemming is not easy | 172 | # choosing a place for the synonym filter when stemming is not easy |
173 | # https://groups.google.com/forum/#!topic/elasticsearch/p7qcQlgHdB8 | 173 | # https://groups.google.com/forum/#!topic/elasticsearch/p7qcQlgHdB8 |
test/synonyms_test.rb
@@ -59,4 +59,9 @@ class SynonymsTest < Minitest::Test | @@ -59,4 +59,9 @@ class SynonymsTest < Minitest::Test | ||
59 | assert_search "Halogen Lamp", ["Lightbulb"] | 59 | assert_search "Halogen Lamp", ["Lightbulb"] |
60 | assert_search "onions", ["Green Onions"] | 60 | assert_search "onions", ["Green Onions"] |
61 | end | 61 | end |
62 | + | ||
63 | + def test_case | ||
64 | + store_names ["Uppercase"] | ||
65 | + assert_search "lowercase", ["Uppercase"] | ||
66 | + end | ||
62 | end | 67 | end |
test/test_helper.rb
@@ -372,6 +372,7 @@ class Product | @@ -372,6 +372,7 @@ class Product | ||
372 | ["qtip", "cottonswab"], | 372 | ["qtip", "cottonswab"], |
373 | ["burger", "hamburger"], | 373 | ["burger", "hamburger"], |
374 | ["bandaid", "bandag"], | 374 | ["bandaid", "bandag"], |
375 | + ["UPPERCASE", "lowercase"], | ||
375 | "lightbulb => led,lightbulb", | 376 | "lightbulb => led,lightbulb", |
376 | "lightbulb => halogenlamp" | 377 | "lightbulb => halogenlamp" |
377 | ], | 378 | ], |