Skip to content

Commit c8a650b

Browse files
committed
Dropped support for Elasticsearch 7 and OpenSearch 1
1 parent 414b5cc commit c8a650b

File tree

14 files changed

+40
-162
lines changed

14 files changed

+40
-162
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,13 @@ jobs:
2424
- ruby: 3.3
2525
gemfile: gemfiles/opensearch2.gemfile
2626
opensearch: 2.19.2
27-
- ruby: 3.2
28-
gemfile: gemfiles/opensearch1.gemfile
29-
opensearch: 1.3.20
3027
- ruby: 3.3
3128
gemfile: gemfiles/mongoid9.gemfile
32-
elasticsearch: 7.17.29
29+
elasticsearch: 8
3330
mongodb: true
3431
- ruby: 3.2
3532
gemfile: gemfiles/mongoid8.gemfile
36-
elasticsearch: 7.0.0
33+
elasticsearch: 8
3734
mongodb: true
3835
runs-on: ubuntu-latest
3936
env:

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 6.0.0 (unreleased)
2+
3+
- Dropped support for Elasticsearch 7 and OpenSearch 1
4+
15
## 5.5.2 (2025-05-20)
26

37
- Fixed `scope` option for partial reindex

gemfiles/activerecord71.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ gem "sqlite3", "< 2"
88
gem "activerecord", "~> 7.1.0"
99
gem "actionpack", "~> 7.1.0"
1010
gem "activejob", "~> 7.1.0", require: "active_job"
11-
gem "elasticsearch", "~> 7"
11+
gem "elasticsearch", "~> 8"
1212
gem "redis-client"
1313
gem "connection_pool"
1414
gem "kaminari"

gemfiles/mongoid8.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ gem "minitest", ">= 5"
77
gem "mongoid", "~> 8", "< 8.1.3"
88
gem "activejob", require: "active_job"
99
gem "redis"
10-
gem "elasticsearch", "~> 7"
10+
gem "elasticsearch", "~> 8"
1111
gem "actionpack"
1212
gem "kaminari"
1313
gem "gemoji-parser"

gemfiles/opensearch1.gemfile

Lines changed: 0 additions & 17 deletions
This file was deleted.

lib/searchkick/index.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ def reload_synonyms
192192
if Searchkick.opensearch?
193193
client.transport.perform_request "POST", "_plugins/_refresh_search_analyzers/#{CGI.escape(name)}"
194194
else
195-
raise Error, "Requires Elasticsearch 7.3+" if Searchkick.server_below?("7.3.0")
196195
begin
197196
client.transport.perform_request("GET", "#{CGI.escape(name)}/_reload_search_analyzers")
198197
rescue => e

lib/searchkick/index_options.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,9 @@ def add_search_synonyms(settings)
578578
if search_synonyms.is_a?(String)
579579
synonym_graph = {
580580
type: "synonym_graph",
581-
synonyms_path: search_synonyms
581+
synonyms_path: search_synonyms,
582+
updateable: true
582583
}
583-
synonym_graph[:updateable] = true unless below73?
584584
else
585585
synonym_graph = {
586586
type: "synonym_graph",
@@ -628,9 +628,5 @@ def default_type
628628
def default_analyzer
629629
:searchkick_index
630630
end
631-
632-
def below73?
633-
Searchkick.server_below?("7.3.0")
634-
end
635631
end
636632
end

lib/searchkick/query.rb

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ def prepare
374374
field_misspellings = misspellings && (!misspellings_fields || misspellings_fields.include?(base_field(field)))
375375

376376
if field == "_all" || field.end_with?(".analyzed")
377-
shared_options[:cutoff_frequency] = 0.001 unless operator.to_s == "and" || field_misspellings == false || (!below73? && !track_total_hits?) || match_type == :match_phrase || !below80? || Searchkick.opensearch?
378377
qs << shared_options.merge(analyzer: "searchkick_search")
379378

380379
# searchkick_search and searchkick_search2 are the same for some languages
@@ -457,20 +456,14 @@ def prepare
457456

458457
models = Array(options[:models])
459458
if models.any? { |m| m != m.searchkick_klass }
460-
# aliases are not supported with _index in ES below 7.5
461-
# see https://github.com/elastic/elasticsearch/pull/46640
462-
if below75?
463-
Searchkick.warn("Passing child models to models option throws off hits and pagination - use type option instead")
464-
else
465-
index_type_or =
466-
models.map do |m|
467-
v = {_index: m.searchkick_index.name}
468-
v[:type] = m.searchkick_index.klass_document_type(m, true) if m != m.searchkick_klass
469-
v
470-
end
459+
index_type_or =
460+
models.map do |m|
461+
v = {_index: m.searchkick_index.name}
462+
v[:type] = m.searchkick_index.klass_document_type(m, true) if m != m.searchkick_klass
463+
v
464+
end
471465

472-
where[:or] = Array(where[:or]) + [index_type_or]
473-
end
466+
where[:or] = Array(where[:or]) + [index_type_or]
474467
end
475468

476469
# start everything as efficient filters
@@ -1113,11 +1106,7 @@ def where_filters(where)
11131106
regex = regex.gsub(/(?<!\\)%/, ".*").gsub(/(?<!\\)_/, ".").gsub("\\%", "%").gsub("\\_", "_")
11141107

11151108
if op == :ilike
1116-
if below710?
1117-
raise ArgumentError, "ilike requires Elasticsearch 7.10+"
1118-
else
1119-
filters << {regexp: {field => {value: regex, flags: "NONE", case_insensitive: true}}}
1120-
end
1109+
filters << {regexp: {field => {value: regex, flags: "NONE", case_insensitive: true}}}
11211110
else
11221111
filters << {regexp: {field => {value: regex, flags: "NONE"}}}
11231112
end
@@ -1201,14 +1190,7 @@ def term_filters(field, value)
12011190
source = "#{source}.*"
12021191
end
12031192

1204-
if below710?
1205-
if value.casefold?
1206-
raise ArgumentError, "Case-insensitive flag does not work with Elasticsearch < 7.10"
1207-
end
1208-
{regexp: {field => {value: source, flags: "NONE"}}}
1209-
else
1210-
{regexp: {field => {value: source, flags: "NONE", case_insensitive: value.casefold?}}}
1211-
end
1193+
{regexp: {field => {value: source, flags: "NONE", case_insensitive: value.casefold?}}}
12121194
else
12131195
# TODO add this for other values
12141196
if value.as_json.is_a?(Enumerable)
@@ -1300,22 +1282,6 @@ def body_options
13001282
options[:body_options] || {}
13011283
end
13021284

1303-
def below73?
1304-
Searchkick.server_below?("7.3.0")
1305-
end
1306-
1307-
def below75?
1308-
Searchkick.server_below?("7.5.0")
1309-
end
1310-
1311-
def below710?
1312-
Searchkick.server_below?("7.10.0")
1313-
end
1314-
1315-
def below80?
1316-
Searchkick.server_below?("8.0.0")
1317-
end
1318-
13191285
def below90?
13201286
Searchkick.server_below?("9.0.0")
13211287
end

test/aggs_test.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def test_aggs_group_by_date
113113
products_per_year: {
114114
date_histogram: {
115115
field: :created_at,
116-
interval_key => :year
116+
calendar_interval: :year
117117
}
118118
}
119119
}
@@ -241,7 +241,7 @@ def search_aggregate_by_day_with_time_zone(query, time_zone = '-8:00')
241241
products_per_day: {
242242
date_histogram: {
243243
field: :created_at,
244-
interval_key => :day,
244+
calendar_interval: :day,
245245
time_zone: time_zone
246246
}
247247
}
@@ -263,8 +263,4 @@ def store_multiple_aggs(options)
263263
[field, buckets_as_hash(filtered_agg)]
264264
end
265265
end
266-
267-
def interval_key
268-
Searchkick.server_below?("7.4.0") ? :interval : :calendar_interval
269-
end
270266
end

test/inheritance_test.rb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,8 @@ def test_inherited_and_non_inherited_models
104104
store_names ["Bear C"]
105105
Animal.reindex
106106
assert_equal 2, Searchkick.search("bear", models: [Cat, Product]).size
107-
108-
# hits and pagination will be off with this approach (for now)
109-
# ideal case is add where conditions (index a, type a OR index b)
110-
# however, we don't know the exact index name and aliases don't work for filters
111-
# see https://github.com/elastic/elasticsearch/issues/23306
112-
# show warning for now
113-
# alternative is disallow inherited models with models option
114-
expected = Searchkick.server_below?("7.5.0") ? 3 : 2
115-
assert_equal expected, Searchkick.search("bear", models: [Cat, Product]).hits.size
116-
assert_equal expected, Searchkick.search("bear", models: [Cat, Product], per_page: 1).total_pages
107+
assert_equal 2, Searchkick.search("bear", models: [Cat, Product]).hits.size
108+
assert_equal 2, Searchkick.search("bear", models: [Cat, Product], per_page: 1).total_pages
117109
end
118110

119111
# TODO move somewhere better

0 commit comments

Comments
 (0)