Commit b715e9e3c0e7cb96f8d66f90f4c919f8510cba14
1 parent
b888bfe2
Exists in
master
and in
19 other branches
Removed support for ES2 [skip ci]
Showing
10 changed files
with
17 additions
and
79 deletions
Show diff stats
.travis.yml
... | ... | @@ -24,13 +24,6 @@ env: |
24 | 24 | jdk: oraclejdk8 |
25 | 25 | matrix: |
26 | 26 | include: |
27 | - - gemfile: Gemfile | |
28 | - env: ELASTICSEARCH_VERSION=2.0.0 | |
29 | - jdk: oraclejdk7 | |
30 | - - gemfile: Gemfile | |
31 | - env: ELASTICSEARCH_VERSION=2.4.6 | |
32 | - jdk: oraclejdk7 | |
33 | - - gemfile: Gemfile | |
34 | 27 | env: ELASTICSEARCH_VERSION=5.0.1 |
35 | 28 | jdk: oraclejdk8 |
36 | 29 | - gemfile: Gemfile | ... | ... |
CHANGELOG.md
README.md
... | ... | @@ -535,7 +535,7 @@ class Image < ApplicationRecord |
535 | 535 | after_commit :reindex_product |
536 | 536 | |
537 | 537 | def reindex_product |
538 | - product.reindex # or reindex_async | |
538 | + product.reindex | |
539 | 539 | end |
540 | 540 | end |
541 | 541 | ``` |
... | ... | @@ -1531,8 +1531,6 @@ Reindex one record |
1531 | 1531 | ```ruby |
1532 | 1532 | product = Product.find(1) |
1533 | 1533 | product.reindex |
1534 | -# or to reindex in the background | |
1535 | -product.reindex_async | |
1536 | 1534 | ``` |
1537 | 1535 | |
1538 | 1536 | Reindex multiple records | ... | ... |
lib/searchkick/model.rb
... | ... | @@ -79,12 +79,11 @@ module Searchkick |
79 | 79 | end |
80 | 80 | end |
81 | 81 | |
82 | - callback_name = callbacks == :async ? :reindex_async : :reindex | |
83 | 82 | if respond_to?(:after_commit) |
84 | - after_commit callback_name, if: proc { self.class.search_callbacks? } | |
83 | + after_commit :reindex, if: -> { self.class.search_callbacks? } | |
85 | 84 | elsif respond_to?(:after_save) |
86 | - after_save callback_name, if: proc { self.class.search_callbacks? } | |
87 | - after_destroy callback_name, if: proc { self.class.search_callbacks? } | |
85 | + after_save :reindex, if: -> { self.class.search_callbacks? } | |
86 | + after_destroy :reindex, if: -> { self.class.search_callbacks? } | |
88 | 87 | end |
89 | 88 | |
90 | 89 | def reindex(method_name = nil, refresh: false, async: false, mode: nil) |
... | ... | @@ -96,8 +95,7 @@ module Searchkick |
96 | 95 | :async |
97 | 96 | elsif Searchkick.callbacks_value |
98 | 97 | Searchkick.callbacks_value |
99 | - elsif klass_options.key?(:callbacks) && klass_options[:callbacks] != :async | |
100 | - # TODO remove 2nd condition in next major version | |
98 | + elsif klass_options.key?(:callbacks) | |
101 | 99 | klass_options[:callbacks] |
102 | 100 | end |
103 | 101 | end |
... | ... | @@ -130,11 +128,6 @@ module Searchkick |
130 | 128 | end |
131 | 129 | end unless method_defined?(:reindex) |
132 | 130 | |
133 | - # TODO remove this method in next major version | |
134 | - def reindex_async | |
135 | - reindex(async: true) | |
136 | - end unless method_defined?(:reindex_async) | |
137 | - | |
138 | 131 | def similar(options = {}) |
139 | 132 | self.class.searchkick_index.similar_record(self, options) |
140 | 133 | end unless method_defined?(:similar) | ... | ... |
test/boost_test.rb
... | ... | @@ -122,13 +122,7 @@ class BoostTest < Minitest::Test |
122 | 122 | {name: "Tomato B", orders_count: 10}, |
123 | 123 | ] |
124 | 124 | |
125 | - if elasticsearch_below50? | |
126 | - assert_raises(ArgumentError) do | |
127 | - assert_order "tomato", ["Tomato A", "Tomato B"], boost_by: {orders_count: {missing: 100}} | |
128 | - end | |
129 | - else | |
130 | - assert_order "tomato", ["Tomato A", "Tomato B"], boost_by: {orders_count: {missing: 100}} | |
131 | - end | |
125 | + assert_order "tomato", ["Tomato A", "Tomato B"], boost_by: {orders_count: {missing: 100}} | |
132 | 126 | end |
133 | 127 | |
134 | 128 | def test_boost_by_boost_mode_multiply | ... | ... |
test/geo_shape_test.rb
test/index_test.rb
... | ... | @@ -131,9 +131,10 @@ class IndexTest < Minitest::Test |
131 | 131 | def test_filterable |
132 | 132 | # skip for 5.0 since it throws |
133 | 133 | # Cannot search on field [alt_description] since it is not indexed. |
134 | - skip unless elasticsearch_below50? | |
135 | 134 | store [{name: "Product A", alt_description: "Hello"}] |
136 | - assert_search "*", [], where: {alt_description: "Hello"} | |
135 | + assert_raises(Searchkick::InvalidQueryError) do | |
136 | + assert_search "*", [], where: {alt_description: "Hello"} | |
137 | + end | |
137 | 138 | end |
138 | 139 | |
139 | 140 | def test_filterable_non_string |
... | ... | @@ -155,7 +156,7 @@ class IndexTest < Minitest::Test |
155 | 156 | end |
156 | 157 | |
157 | 158 | def test_very_large_value |
158 | - skip if nobrainer? || elasticsearch_below22? | |
159 | + skip if nobrainer? | |
159 | 160 | large_value = 10000.times.map { "hello" }.join(" ") |
160 | 161 | store [{name: "Product A", text: large_value}], Region |
161 | 162 | assert_search "product", ["Product A"], {}, Region | ... | ... |
test/order_test.rb
... | ... | @@ -29,14 +29,8 @@ class OrderTest < Minitest::Test |
29 | 29 | assert_order "product", ["Product A", "Product B", "Product C"], order: {color: :asc, store_id: :desc} |
30 | 30 | end |
31 | 31 | |
32 | - def test_order_ignore_unmapped | |
33 | - skip unless elasticsearch_below50? | |
34 | - assert_order "product", [], order: {not_mapped: {ignore_unmapped: true}}, conversions: false | |
35 | - end | |
36 | - | |
37 | 32 | def test_order_unmapped_type |
38 | - skip if elasticsearch_below50? | |
39 | - assert_order "product", [], order: {not_mapped: {unmapped_type: "long"}}, conversions: false | |
33 | + assert_order "product", [], order: {not_mapped: {unmapped_type: "long"}} | |
40 | 34 | end |
41 | 35 | |
42 | 36 | def test_order_array | ... | ... |
test/sql_test.rb
... | ... | @@ -125,36 +125,7 @@ class SqlTest < Minitest::Test |
125 | 125 | assert_nil hit["_source"] |
126 | 126 | end |
127 | 127 | |
128 | - def test_select_include | |
129 | - skip unless elasticsearch_below50? | |
130 | - store [{name: "Product A", user_ids: [1, 2]}] | |
131 | - result = Product.search("product", load: false, select: {include: [:name]}).first | |
132 | - assert_equal %w(id name), result.keys.reject { |k| k.start_with?("_") }.sort | |
133 | - assert_equal "Product A", result.name | |
134 | - assert_nil result.store_id | |
135 | - end | |
136 | - | |
137 | - def test_select_exclude | |
138 | - skip unless elasticsearch_below50? | |
139 | - store [{name: "Product A", user_ids: [1, 2], store_id: 1}] | |
140 | - result = Product.search("product", load: false, select: {exclude: [:name]}).first | |
141 | - assert_nil result.name | |
142 | - assert_equal [1, 2], result.user_ids | |
143 | - assert_equal 1, result.store_id | |
144 | - end | |
145 | - | |
146 | - def test_select_include_and_exclude | |
147 | - skip unless elasticsearch_below50? | |
148 | - # let's take this to the next level | |
149 | - store [{name: "Product A", user_ids: [1, 2], store_id: 1}] | |
150 | - result = Product.search("product", load: false, select: {include: [:store_id], exclude: [:name]}).first | |
151 | - assert_equal 1, result.store_id | |
152 | - assert_nil result.name | |
153 | - assert_nil result.user_ids | |
154 | - end | |
155 | - | |
156 | 128 | def test_select_includes |
157 | - skip if elasticsearch_below50? | |
158 | 129 | store [{name: "Product A", user_ids: [1, 2]}] |
159 | 130 | result = Product.search("product", load: false, select: {includes: [:name]}).first |
160 | 131 | assert_equal %w(id name), result.keys.reject { |k| k.start_with?("_") }.sort |
... | ... | @@ -163,7 +134,6 @@ class SqlTest < Minitest::Test |
163 | 134 | end |
164 | 135 | |
165 | 136 | def test_select_excludes |
166 | - skip if elasticsearch_below50? | |
167 | 137 | store [{name: "Product A", user_ids: [1, 2], store_id: 1}] |
168 | 138 | result = Product.search("product", load: false, select: {excludes: [:name]}).first |
169 | 139 | assert_nil result.name |
... | ... | @@ -172,7 +142,6 @@ class SqlTest < Minitest::Test |
172 | 142 | end |
173 | 143 | |
174 | 144 | def test_select_include_and_excludes |
175 | - skip if elasticsearch_below50? | |
176 | 145 | # let's take this to the next level |
177 | 146 | store [{name: "Product A", user_ids: [1, 2], store_id: 1}] |
178 | 147 | result = Product.search("product", load: false, select: {includes: [:store_id], excludes: [:name]}).first | ... | ... |
test/test_helper.rb
... | ... | @@ -38,18 +38,10 @@ end |
38 | 38 | |
39 | 39 | ActiveSupport::LogSubscriber.logger = ActiveSupport::Logger.new(STDOUT) if ENV["NOTIFICATIONS"] |
40 | 40 | |
41 | -def elasticsearch_below50? | |
42 | - Searchkick.server_below?("5.0.0-alpha1") | |
43 | -end | |
44 | - | |
45 | 41 | def elasticsearch_below60? |
46 | 42 | Searchkick.server_below?("6.0.0-alpha1") |
47 | 43 | end |
48 | 44 | |
49 | -def elasticsearch_below22? | |
50 | - Searchkick.server_below?("2.2.0") | |
51 | -end | |
52 | - | |
53 | 45 | def nobrainer? |
54 | 46 | defined?(NoBrainer) |
55 | 47 | end |
... | ... | @@ -454,7 +446,7 @@ class Store |
454 | 446 | mappings: { |
455 | 447 | store: { |
456 | 448 | properties: { |
457 | - name: elasticsearch_below50? ? {type: "string", analyzer: "keyword"} : {type: "keyword"} | |
449 | + name: {type: "keyword"} | |
458 | 450 | } |
459 | 451 | } |
460 | 452 | } | ... | ... |