Commit 6568ac52f2231974aecb40d13b3f26c404408aff

Authored by Andrew
1 parent b8fe2f0a

Renamed type option to _type [skip ci]

CHANGELOG.md
1 1 ## 2.3.3 [unreleased]
2 2  
3 3 - Fixed `similar` for Elasticsearch 6
4   -- Added `type` option
  4 +- Added `_type` option
5 5  
6 6 ## 2.3.2
7 7  
... ...
lib/searchkick/index.rb
... ... @@ -322,8 +322,8 @@ module Searchkick
322 322 @klass_document_type[klass] ||= begin
323 323 if klass.respond_to?(:document_type)
324 324 klass.document_type
325   - elsif klass.searchkick_klass.searchkick_options[:type]
326   - klass.searchkick_klass.searchkick_options[:type]
  325 + elsif klass.searchkick_klass.searchkick_options[:_type]
  326 + klass.searchkick_klass.searchkick_options[:_type]
327 327 else
328 328 klass.model_name.to_s.underscore
329 329 end
... ...
lib/searchkick/index_options.rb
... ... @@ -4,7 +4,7 @@ module Searchkick
4 4 options = @options
5 5 language = options[:language]
6 6 language = language.call if language.respond_to?(:call)
7   - type = options[:type] || :_default_
  7 + type = options[:_type] || :_default_
8 8 type = type.call if type.respond_to?(:call)
9 9  
10 10 if options[:mappings] && !options[:merge_mappings]
... ...
lib/searchkick/model.rb
1 1 module Searchkick
2 2 module Model
3 3 def searchkick(**options)
4   - unknown_keywords = options.keys - [:_all, :batch_size, :callbacks, :conversions, :default_fields,
  4 + unknown_keywords = options.keys - [:_all, :_type, :batch_size, :callbacks, :conversions, :default_fields,
5 5 :filterable, :geo_shape, :highlight, :ignore_above, :index_name, :index_prefix, :language,
6 6 :locations, :mappings, :match, :merge_mappings, :routing, :searchable, :settings, :similarity,
7 7 :special_characters, :stem_conversions, :suggest, :synonyms, :text_end,
8   - :text_middle, :text_start, :type, :word, :wordnet, :word_end, :word_middle, :word_start]
  8 + :text_middle, :text_start, :word, :wordnet, :word_end, :word_middle, :word_start]
9 9 raise ArgumentError, "unknown keywords: #{unknown_keywords.join(", ")}" if unknown_keywords.any?
10 10  
11 11 raise "Only call searchkick once per model" if respond_to?(:searchkick_index)
... ...
test/test_helper.rb
... ... @@ -505,7 +505,7 @@ end
505 505 class Animal
506 506 searchkick \
507 507 default_fields: elasticsearch_below60? ? nil : [:name],
508   - type: elasticsearch_below60? ? nil : :animal,
  508 + _type: elasticsearch_below60? ? nil : :animal,
509 509 text_start: [:name],
510 510 suggest: [:name],
511 511 index_name: -> { "#{name.tableize}-#{Date.today.year}#{Searchkick.index_suffix}" },
... ...