From 1cc40079b58308730f684fa51cbf08779b59848b Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 2 May 2017 19:58:52 -0700 Subject: [PATCH] No longer require synonyms to be lowercase - #912 --- CHANGELOG.md | 1 + lib/searchkick/index_options.rb | 2 +- test/synonyms_test.rb | 5 +++++ test/test_helper.rb | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b5cd3f..3ae8742 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 2.2.2 [unreleased] - Added `queue_name` option +- No longer require synonyms to be lowercase ## 2.2.1 diff --git a/lib/searchkick/index_options.rb b/lib/searchkick/index_options.rb index 3ff76f0..17b2bd4 100644 --- a/lib/searchkick/index_options.rb +++ b/lib/searchkick/index_options.rb @@ -167,7 +167,7 @@ module Searchkick if synonyms.any? settings[:analysis][:filter][:searchkick_synonym] = { type: "synonym", - synonyms: synonyms.select { |s| s.size > 1 }.map { |s| s.is_a?(Array) ? s.join(",") : s } + synonyms: synonyms.select { |s| s.size > 1 }.map { |s| s.is_a?(Array) ? s.join(",") : s }.map(&:downcase) } # choosing a place for the synonym filter when stemming is not easy # https://groups.google.com/forum/#!topic/elasticsearch/p7qcQlgHdB8 diff --git a/test/synonyms_test.rb b/test/synonyms_test.rb index f9b3886..262fe18 100644 --- a/test/synonyms_test.rb +++ b/test/synonyms_test.rb @@ -59,4 +59,9 @@ class SynonymsTest < Minitest::Test assert_search "Halogen Lamp", ["Lightbulb"] assert_search "onions", ["Green Onions"] end + + def test_case + store_names ["Uppercase"] + assert_search "lowercase", ["Uppercase"] + end end diff --git a/test/test_helper.rb b/test/test_helper.rb index c151d6b..083d6e9 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -372,6 +372,7 @@ class Product ["qtip", "cottonswab"], ["burger", "hamburger"], ["bandaid", "bandag"], + ["UPPERCASE", "lowercase"], "lightbulb => led,lightbulb", "lightbulb => halogenlamp" ], -- libgit2 0.21.0