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 | ## 2.2.2 [unreleased] | 1 | ## 2.2.2 [unreleased] |
2 | 2 | ||
3 | +- Fixed analyzer on dynamically mapped fields | ||
4 | +- Fixed error with `similar` method and `_all` field | ||
3 | - Added `queue_name` option | 5 | - Added `queue_name` option |
4 | - No longer require synonyms to be lowercase | 6 | - No longer require synonyms to be lowercase |
5 | -- Fixed error with `similar` method and `_all` field | ||
6 | 7 | ||
7 | ## 2.2.1 | 8 | ## 2.2.1 |
8 | 9 |
lib/searchkick/index_options.rb
@@ -229,6 +229,8 @@ module Searchkick | @@ -229,6 +229,8 @@ module Searchkick | ||
229 | 229 | ||
230 | mapping_options[:searchable].delete("_all") | 230 | mapping_options[:searchable].delete("_all") |
231 | 231 | ||
232 | + analyzed_field_options = {type: default_type, index: "analyzed", analyzer: default_analyzer} | ||
233 | + | ||
232 | mapping_options.values.flatten.uniq.each do |field| | 234 | mapping_options.values.flatten.uniq.each do |field| |
233 | fields = {} | 235 | fields = {} |
234 | 236 | ||
@@ -240,7 +242,7 @@ module Searchkick | @@ -240,7 +242,7 @@ module Searchkick | ||
240 | 242 | ||
241 | if !options[:searchable] || mapping_options[:searchable].include?(field) | 243 | if !options[:searchable] || mapping_options[:searchable].include?(field) |
242 | if word | 244 | if word |
243 | - fields["analyzed"] = {type: default_type, index: "analyzed", analyzer: default_analyzer} | 245 | + fields["analyzed"] = analyzed_field_options |
244 | 246 | ||
245 | if mapping_options[:highlight].include?(field) | 247 | if mapping_options[:highlight].include?(field) |
246 | fields["analyzed"][:term_vector] = "with_positions_offsets" | 248 | fields["analyzed"][:term_vector] = "with_positions_offsets" |
@@ -294,7 +296,7 @@ module Searchkick | @@ -294,7 +296,7 @@ module Searchkick | ||
294 | end | 296 | end |
295 | 297 | ||
296 | if word | 298 | if word |
297 | - dynamic_fields["analyzed"] = {type: default_type, index: "analyzed"} | 299 | + dynamic_fields["analyzed"] = analyzed_field_options |
298 | end | 300 | end |
299 | end | 301 | end |
300 | 302 | ||
@@ -305,7 +307,7 @@ module Searchkick | @@ -305,7 +307,7 @@ module Searchkick | ||
305 | 307 | ||
306 | mappings = { | 308 | mappings = { |
307 | _default_: { | 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 | properties: mapping, | 311 | properties: mapping, |
310 | _routing: routing, | 312 | _routing: routing, |
311 | # https://gist.github.com/kimchy/2898285 | 313 | # https://gist.github.com/kimchy/2898285 |