Commit ff407187088e5ee870bebca684412ec4078fee25
1 parent
3b0eb3c6
Exists in
master
and in
19 other branches
Strip spaces from synonyms and added notice about two word max - fixes #913
Showing
3 changed files
with
5 additions
and
2 deletions
Show diff stats
README.md
lib/searchkick/index_options.rb
... | ... | @@ -174,7 +174,8 @@ module Searchkick |
174 | 174 | if synonyms.any? |
175 | 175 | settings[:analysis][:filter][:searchkick_synonym] = { |
176 | 176 | type: "synonym", |
177 | - synonyms: synonyms.select { |s| s.size > 1 }.map { |s| s.is_a?(Array) ? s.join(",") : s }.map(&:downcase) | |
177 | + # only remove a single space from synonyms so three-word synonyms will fail noisily instead of silently | |
178 | + synonyms: synonyms.select { |s| s.size > 1 }.map { |s| s.is_a?(Array) ? s.map { |s| s.sub(/\s+/, "") }.join(",") : s }.map(&:downcase) | |
178 | 179 | } |
179 | 180 | # choosing a place for the synonym filter when stemming is not easy |
180 | 181 | # https://groups.google.com/forum/#!topic/elasticsearch/p7qcQlgHdB8 | ... | ... |
test/test_helper.rb
... | ... | @@ -399,7 +399,7 @@ class Product |
399 | 399 | synonyms: [ |
400 | 400 | ["clorox", "bleach"], |
401 | 401 | ["scallion", "greenonion"], |
402 | - ["saranwrap", "plasticwrap"], | |
402 | + ["saran wrap", "plastic wrap"], | |
403 | 403 | ["qtip", "cottonswab"], |
404 | 404 | ["burger", "hamburger"], |
405 | 405 | ["bandaid", "bandag"], | ... | ... |