diff --git a/lib/searchkick/index_options.rb b/lib/searchkick/index_options.rb index 1cf0d75..45f9250 100644 --- a/lib/searchkick/index_options.rb +++ b/lib/searchkick/index_options.rb @@ -11,28 +11,16 @@ module Searchkick settings = options[:settings] || {} mappings = options[:mappings] else - below22 = Searchkick.server_below?("2.2.0") - below50 = Searchkick.server_below?("5.0.0-alpha1") below60 = Searchkick.server_below?("6.0.0-alpha1") - default_type = below50 ? "string" : "text" + default_type = "text" default_analyzer = :searchkick_index - keyword_mapping = - if below50 - { - type: default_type, - index: "not_analyzed" - } - else - { - type: "keyword" - } - end + keyword_mapping = {type: "keyword"} all = options.key?(:_all) ? options[:_all] : below60 - index_true_value = below50 ? "analyzed" : true - index_false_value = below50 ? "no" : false + index_true_value = true + index_false_value = false - keyword_mapping[:ignore_above] = (options[:ignore_above] || 30000) unless below22 + keyword_mapping[:ignore_above] = options[:ignore_above] || 30000 settings = { analysis: { diff --git a/lib/searchkick/query.rb b/lib/searchkick/query.rb index 3a7baee..26d7ba9 100644 --- a/lib/searchkick/query.rb +++ b/lib/searchkick/query.rb @@ -758,7 +758,7 @@ module Searchkick # TODO id transformation for arrays def set_order(payload) order = options[:order].is_a?(Enumerable) ? options[:order] : {options[:order] => :asc} - id_field = below50? ? :_id : :_uid + id_field = :_uid payload[:sort] = order.is_a?(Array) ? order : Hash[order.map { |k, v| [k.to_s == "id" ? id_field : k, v] }] end @@ -889,21 +889,10 @@ module Searchkick end def custom_filter(field, value, factor) - if below50? - { - filter: { - bool: { - must: where_filters(field => value) - } - }, - boost_factor: factor - } - else - { - filter: where_filters(field => value), - weight: factor - } - end + { + filter: where_filters(field => value), + weight: factor + } end def boost_filters(boost_by, options = {}) @@ -919,11 +908,7 @@ module Searchkick } if value[:missing] - if below50? - raise ArgumentError, "The missing option for boost_by is not supported in Elasticsearch < 5" - else - script_score[:field_value_factor][:missing] = value[:missing].to_f - end + script_score[:field_value_factor][:missing] = value[:missing].to_f else script_score[:filter] = { exists: { @@ -957,10 +942,6 @@ module Searchkick end end - def below50? - Searchkick.server_below?("5.0.0-alpha1") - end - def below60? Searchkick.server_below?("6.0.0-alpha1") end -- libgit2 0.21.0