Commit 1008d10ac3512d404d090d7a73c8415e9a160350
1 parent
148a213e
Exists in
master
and in
19 other branches
Fixed analyzer on dynamically mapped fields - fixes #914
Showing
2 changed files
with
7 additions
and
4 deletions
Show diff stats
CHANGELOG.md
1 | 1 | ## 2.2.2 [unreleased] |
2 | 2 | |
3 | +- Fixed analyzer on dynamically mapped fields | |
4 | +- Fixed error with `similar` method and `_all` field | |
3 | 5 | - Added `queue_name` option |
4 | 6 | - No longer require synonyms to be lowercase |
5 | -- Fixed error with `similar` method and `_all` field | |
6 | 7 | |
7 | 8 | ## 2.2.1 |
8 | 9 | ... | ... |
lib/searchkick/index_options.rb
... | ... | @@ -229,6 +229,8 @@ module Searchkick |
229 | 229 | |
230 | 230 | mapping_options[:searchable].delete("_all") |
231 | 231 | |
232 | + analyzed_field_options = {type: default_type, index: "analyzed", analyzer: default_analyzer} | |
233 | + | |
232 | 234 | mapping_options.values.flatten.uniq.each do |field| |
233 | 235 | fields = {} |
234 | 236 | |
... | ... | @@ -240,7 +242,7 @@ module Searchkick |
240 | 242 | |
241 | 243 | if !options[:searchable] || mapping_options[:searchable].include?(field) |
242 | 244 | if word |
243 | - fields["analyzed"] = {type: default_type, index: "analyzed", analyzer: default_analyzer} | |
245 | + fields["analyzed"] = analyzed_field_options | |
244 | 246 | |
245 | 247 | if mapping_options[:highlight].include?(field) |
246 | 248 | fields["analyzed"][:term_vector] = "with_positions_offsets" |
... | ... | @@ -294,7 +296,7 @@ module Searchkick |
294 | 296 | end |
295 | 297 | |
296 | 298 | if word |
297 | - dynamic_fields["analyzed"] = {type: default_type, index: "analyzed"} | |
299 | + dynamic_fields["analyzed"] = analyzed_field_options | |
298 | 300 | end |
299 | 301 | end |
300 | 302 | |
... | ... | @@ -305,7 +307,7 @@ module Searchkick |
305 | 307 | |
306 | 308 | mappings = { |
307 | 309 | _default_: { |
308 | - _all: all_enabled ? {type: default_type, index: "analyzed", analyzer: default_analyzer} : {enabled: false}, | |
310 | + _all: all_enabled ? analyzed_field_options : {enabled: false}, | |
309 | 311 | properties: mapping, |
310 | 312 | _routing: routing, |
311 | 313 | # https://gist.github.com/kimchy/2898285 | ... | ... |