lib/searchkick/index_options.rb in searchkick-2.3.2 vs lib/searchkick/index_options.rb in searchkick-2.4.0

- old
+ new

@@ -2,10 +2,12 @@ module IndexOptions def index_options options = @options language = options[:language] language = language.call if language.respond_to?(:call) + type = options[:_type] || :_default_ + type = type.call if type.respond_to?(:call) if options[:mappings] && !options[:merge_mappings] settings = options[:settings] || {} mappings = options[:mappings] else @@ -273,10 +275,14 @@ options[:geo_shape] = options[:geo_shape].product([{}]).to_h if options[:geo_shape].is_a?(Array) (options[:geo_shape] || {}).each do |field, shape_options| mapping[field] = shape_options.merge(type: "geo_shape") end + if options[:inheritance] + mapping[:type] = keyword_mapping + end + routing = {} if options[:routing] routing = {required: true} unless options[:routing] == true routing[:path] = options[:routing].to_s @@ -311,11 +317,11 @@ # http://www.elasticsearch.org/guide/reference/mapping/multi-field-type/ multi_field = dynamic_fields["{name}"].merge(fields: dynamic_fields.except("{name}")) mappings = { - _default_: { + type => { properties: mapping, _routing: routing, # https://gist.github.com/kimchy/2898285 dynamic_templates: [ { @@ -329,10 +335,10 @@ } } if below60 all_enabled = all && (!options[:searchable] || options[:searchable].to_a.map(&:to_s).include?("_all")) - mappings[:_default_][:_all] = all_enabled ? analyzed_field_options : {enabled: false} + mappings[type][:_all] = all_enabled ? analyzed_field_options : {enabled: false} end mappings = mappings.deep_merge(options[:mappings] || {}) end