Commit a0d94a510d843ab6a7d054b58dc664832d6e9426

Authored by Andrew Kane
1 parent 02b15a8f

Dropped support for Elasticsearch 6

CHANGELOG.md
... ... @@ -7,6 +7,7 @@
7 7 - Removed mapping of `id` to `_id` with `order` option
8 8 - Removed `wordnet` option
9 9 - Removed `elasticsearch` dependency
  10 +- Dropped support for Elasticsearch 6
10 11 - Dropped support for Ruby < 2.6 and Active Record < 5.2
11 12 - Dropped support for NoBrainer and Cequel
12 13 - Dropped support for `faraday_middleware-aws-signers-v4` (use `faraday_middleware-aws-sigv4` instead)
... ...
lib/searchkick.rb
... ... @@ -123,14 +123,6 @@ module Searchkick
123 123 Gem::Version.new(server_version.split("-")[0]) < Gem::Version.new(version.split("-")[0])
124 124 end
125 125  
126   - # memoize for performance
127   - def self.server_below7?
128   - unless defined?(@server_below7)
129   - @server_below7 = server_below?("7.0.0")
130   - end
131   - @server_below7
132   - end
133   -
134 126 def self.search(term = "*", model: nil, **options, &block)
135 127 options = options.dup
136 128 klass = model
... ...
lib/searchkick/index_options.rb
... ... @@ -8,10 +8,6 @@ module Searchkick
8 8  
9 9 def index_options
10 10 custom_mapping = options[:mappings] || {}
11   - if below70? && custom_mapping.keys.map(&:to_sym).include?(:properties)
12   - # add type
13   - custom_mapping = {index_type => custom_mapping}
14   - end
15 11  
16 12 if options[:mappings] && !options[:merge_mappings]
17 13 settings = options[:settings] || {}
... ... @@ -167,12 +163,10 @@ module Searchkick
167 163 settings[:similarity] = {default: {type: options[:similarity]}}
168 164 end
169 165  
170   - unless below62?
171   - settings[:index] = {
172   - max_ngram_diff: 49,
173   - max_shingle_diff: 4
174   - }
175   - end
  166 + settings[:index] = {
  167 + max_ngram_diff: 49,
  168 + max_shingle_diff: 4
  169 + }
176 170  
177 171 if options[:case_sensitive]
178 172 settings[:analysis][:analyzer].each do |_, analyzer|
... ... @@ -467,10 +461,6 @@ module Searchkick
467 461 ]
468 462 }
469 463  
470   - if below70?
471   - mappings = {index_type => mappings}
472   - end
473   -
474 464 mappings
475 465 end
476 466  
... ... @@ -558,14 +548,6 @@ module Searchkick
558 548 :searchkick_index
559 549 end
560 550  
561   - def below62?
562   - Searchkick.server_below?("6.2.0")
563   - end
564   -
565   - def below70?
566   - Searchkick.server_below?("7.0.0")
567   - end
568   -
569 551 def below73?
570 552 Searchkick.server_below?("7.3.0")
571 553 end
... ...
lib/searchkick/query.rb
... ... @@ -384,11 +384,6 @@ module Searchkick
384 384  
385 385 if field.start_with?("*.")
386 386 q2 = qs.map { |q| {multi_match: q.merge(fields: [field], type: match_type == :match_phrase ? "phrase" : "best_fields")} }
387   - if below61?
388   - q2.each do |q|
389   - q[:multi_match].delete(:fuzzy_transpositions)
390   - end
391   - end
392 387 else
393 388 q2 = qs.map { |q| {match_type => {field => q}} }
394 389 end
... ... @@ -1141,21 +1136,13 @@ module Searchkick
1141 1136 end
1142 1137  
1143 1138 def track_total_hits?
1144   - (searchkick_options[:deep_paging] && !below70?) || body_options[:track_total_hits]
  1139 + searchkick_options[:deep_paging] || body_options[:track_total_hits]
1145 1140 end
1146 1141  
1147 1142 def body_options
1148 1143 options[:body_options] || {}
1149 1144 end
1150 1145  
1151   - def below61?
1152   - Searchkick.server_below?("6.1.0")
1153   - end
1154   -
1155   - def below70?
1156   - Searchkick.server_below?("7.0.0")
1157   - end
1158   -
1159 1146 def below73?
1160 1147 Searchkick.server_below?("7.3.0")
1161 1148 end
... ...
lib/searchkick/record_data.rb
... ... @@ -39,7 +39,6 @@ module Searchkick
39 39 _index: index.name,
40 40 _id: search_id
41 41 }
42   - data[:_type] = document_type if Searchkick.server_below7?
43 42 data[:routing] = record.search_routing if record.respond_to?(:search_routing)
44 43 data
45 44 end
... ...
test/geo_shape_test.rb
... ... @@ -31,23 +31,6 @@ class GeoShapeTest &lt; Minitest::Test
31 31 ]
32 32 end
33 33  
34   - def test_circle
35   - # https://github.com/elastic/elasticsearch/issues/39237
36   - skip unless Searchkick.server_below?("6.6.0")
37   -
38   - assert_search "*", ["Region A"], {
39   - where: {
40   - territory: {
41   - geo_shape: {
42   - type: "circle",
43   - coordinates: {lat: 28.0, lon: 38.0},
44   - radius: "444000m"
45   - }
46   - }
47   - }
48   - }
49   - end
50   -
51 34 def test_envelope
52 35 assert_search "*", ["Region A"], {
53 36 where: {
... ... @@ -144,23 +127,6 @@ class GeoShapeTest &lt; Minitest::Test
144 127 }
145 128 end
146 129  
147   - def test_contains
148   - # CONTAINS query relation not supported
149   - skip unless Searchkick.server_below?("6.6.0")
150   -
151   - assert_search "*", ["Region C"], {
152   - where: {
153   - territory: {
154   - geo_shape: {
155   - type: "envelope",
156   - relation: "contains",
157   - coordinates: [[12, 13], [13, 12]]
158   - }
159   - }
160   - }
161   - }
162   - end
163   -
164 130 def test_latlon
165 131 assert_search "*", ["Region A"], {
166 132 where: {
... ...
test/index_test.rb
... ... @@ -59,7 +59,6 @@ class IndexTest &lt; Minitest::Test
59 59 store_names ["Dollar Tree"], Store
60 60 assert_equal ["Dollar Tree"], Store.search(body: {query: {match: {name: "dollar"}}}).map(&:name)
61 61 mapping = Store.search_index.mapping.values.first["mappings"]
62   - mapping = mapping["store"] if Searchkick.server_below?("7.0.0")
63 62 assert_equal "text", mapping["properties"]["name"]["type"]
64 63 end
65 64  
... ...
test/language_test.rb
... ... @@ -79,7 +79,7 @@ class LanguageTest &lt; Minitest::Test
79 79 end
80 80  
81 81 def test_korean2
82   - skip if Searchkick.server_below?("6.4.0") || ci?
  82 + skip if ci?
83 83  
84 84 # requires https://www.elastic.co/guide/en/elasticsearch/plugins/7.4/analysis-nori.html
85 85 with_options({language: "korean2"}) do
... ...
test/match_test.rb
... ... @@ -34,8 +34,6 @@ class MatchTest &lt; Minitest::Test
34 34 end
35 35  
36 36 def test_percent
37   - # Note: "2% Milk" doesn't get matched in ES below 5.1.1
38   - # This could be a bug since it has an edit distance of 1
39 37 store_names ["1% Milk", "Whole Milk"]
40 38 assert_search "1%", ["1% Milk"]
41 39 end
... ...
test/routing_test.rb
... ... @@ -8,9 +8,6 @@ class RoutingTest &lt; Minitest::Test
8 8  
9 9 def test_mappings
10 10 mappings = Store.searchkick_index.index_options[:mappings]
11   - if Searchkick.server_below?("7.0.0")
12   - mappings = mappings[:store]
13   - end
14 11 assert_equal mappings[:_routing], required: true
15 12 end
16 13  
... ...