Commit 860874d73b710968791222c31895052c2dfb2263
1 parent
647bb31a
Exists in
master
and in
18 other branches
Added case_sensitive option
Showing
4 changed files
with
23 additions
and
1 deletions
Show diff stats
CHANGELOG.md
lib/searchkick/index_options.rb
... | ... | @@ -225,6 +225,13 @@ module Searchkick |
225 | 225 | } |
226 | 226 | end |
227 | 227 | |
228 | + if options[:case_sensitive] | |
229 | + # delete lowercase analyzer from each | |
230 | + settings[:analysis][:analyzer].each do |_, analyzer| | |
231 | + analyzer[:filter].delete("lowercase") | |
232 | + end | |
233 | + end | |
234 | + | |
228 | 235 | settings = settings.symbolize_keys.deep_merge((options[:settings] || {}).symbolize_keys) |
229 | 236 | |
230 | 237 | # synonyms | ... | ... |
lib/searchkick/model.rb
... | ... | @@ -3,7 +3,7 @@ module Searchkick |
3 | 3 | def searchkick(**options) |
4 | 4 | options = Searchkick.model_options.merge(options) |
5 | 5 | |
6 | - unknown_keywords = options.keys - [:_all, :_type, :batch_size, :callbacks, :conversions, :default_fields, | |
6 | + unknown_keywords = options.keys - [:_all, :_type, :batch_size, :callbacks, :case_sensitive, :conversions, :default_fields, | |
7 | 7 | :filterable, :geo_shape, :highlight, :ignore_above, :index_name, :index_prefix, :inheritance, :language, |
8 | 8 | :locations, :mappings, :match, :merge_mappings, :routing, :searchable, :settings, :similarity, |
9 | 9 | :special_characters, :stem_conversions, :suggest, :synonyms, :text_end, | ... | ... |
... | ... | @@ -0,0 +1,14 @@ |
1 | +require_relative "test_helper" | |
2 | + | |
3 | +class CaseSensitiveTest < Minitest::Test | |
4 | + def setup | |
5 | + Song.destroy_all | |
6 | + end | |
7 | + | |
8 | + def test_case_sensitive | |
9 | + with_options(Song, case_sensitive: true) do | |
10 | + store_names ["Test", "test"], Song | |
11 | + assert_search "test", ["test"], {misspellings: false}, Song | |
12 | + end | |
13 | + end | |
14 | +end | ... | ... |