Commit bac52015076d304c5a48d049ac0def15fc5c6d75

Authored by Andrew
1 parent 28637dfa

Removed below checks

lib/searchkick/index_options.rb
... ... @@ -11,28 +11,16 @@ module Searchkick
11 11 settings = options[:settings] || {}
12 12 mappings = options[:mappings]
13 13 else
14   - below22 = Searchkick.server_below?("2.2.0")
15   - below50 = Searchkick.server_below?("5.0.0-alpha1")
16 14 below60 = Searchkick.server_below?("6.0.0-alpha1")
17   - default_type = below50 ? "string" : "text"
  15 + default_type = "text"
18 16 default_analyzer = :searchkick_index
19   - keyword_mapping =
20   - if below50
21   - {
22   - type: default_type,
23   - index: "not_analyzed"
24   - }
25   - else
26   - {
27   - type: "keyword"
28   - }
29   - end
  17 + keyword_mapping = {type: "keyword"}
30 18  
31 19 all = options.key?(:_all) ? options[:_all] : below60
32   - index_true_value = below50 ? "analyzed" : true
33   - index_false_value = below50 ? "no" : false
  20 + index_true_value = true
  21 + index_false_value = false
34 22  
35   - keyword_mapping[:ignore_above] = (options[:ignore_above] || 30000) unless below22
  23 + keyword_mapping[:ignore_above] = options[:ignore_above] || 30000
36 24  
37 25 settings = {
38 26 analysis: {
... ...
lib/searchkick/query.rb
... ... @@ -758,7 +758,7 @@ module Searchkick
758 758 # TODO id transformation for arrays
759 759 def set_order(payload)
760 760 order = options[:order].is_a?(Enumerable) ? options[:order] : {options[:order] => :asc}
761   - id_field = below50? ? :_id : :_uid
  761 + id_field = :_uid
762 762 payload[:sort] = order.is_a?(Array) ? order : Hash[order.map { |k, v| [k.to_s == "id" ? id_field : k, v] }]
763 763 end
764 764  
... ... @@ -889,21 +889,10 @@ module Searchkick
889 889 end
890 890  
891 891 def custom_filter(field, value, factor)
892   - if below50?
893   - {
894   - filter: {
895   - bool: {
896   - must: where_filters(field => value)
897   - }
898   - },
899   - boost_factor: factor
900   - }
901   - else
902   - {
903   - filter: where_filters(field => value),
904   - weight: factor
905   - }
906   - end
  892 + {
  893 + filter: where_filters(field => value),
  894 + weight: factor
  895 + }
907 896 end
908 897  
909 898 def boost_filters(boost_by, options = {})
... ... @@ -919,11 +908,7 @@ module Searchkick
919 908 }
920 909  
921 910 if value[:missing]
922   - if below50?
923   - raise ArgumentError, "The missing option for boost_by is not supported in Elasticsearch < 5"
924   - else
925   - script_score[:field_value_factor][:missing] = value[:missing].to_f
926   - end
  911 + script_score[:field_value_factor][:missing] = value[:missing].to_f
927 912 else
928 913 script_score[:filter] = {
929 914 exists: {
... ... @@ -957,10 +942,6 @@ module Searchkick
957 942 end
958 943 end
959 944  
960   - def below50?
961   - Searchkick.server_below?("5.0.0-alpha1")
962   - end
963   -
964 945 def below60?
965 946 Searchkick.server_below?("6.0.0-alpha1")
966 947 end
... ...