Commit fd71344152dad5ae59498cbc298cf4bf62ffc846

Authored by Andrew Kane
1 parent 66c4f40c

Removed elasticsearch-xpack dependency for reloadable synonyms

CHANGELOG.md
... ... @@ -2,6 +2,7 @@
2 2  
3 3 - Added support for reloadable synonyms for OpenSearch
4 4 - Added experimental support for `opensearch` gem
  5 +- Removed `elasticsearch-xpack` dependency for reloadable synonyms
5 6  
6 7 ## 4.6.2 (2021-11-15)
7 8  
... ...
Gemfile
... ... @@ -13,5 +13,4 @@ gem "typhoeus"
13 13 gem "redis"
14 14 gem "connection_pool"
15 15 gem "kaminari"
16   -gem "elasticsearch-xpack", ">= 7.8", "< 7.14"
17 16 gem "parallel_tests"
... ...
README.md
... ... @@ -375,9 +375,9 @@ search_synonyms: [&quot;lightbulb =&gt; halogenlamp&quot;]
375 375  
376 376 The above approach works well when your synonym list is static, but in practice, this is often not the case. When you analyze search conversions, you often want to add new synonyms without a full reindex.
377 377  
378   -#### Elasticsearch 7.3+ and OpenSearch
  378 +#### Elasticsearch 7.3+ or OpenSearch
379 379  
380   -For Elasticsearch 7.3+ and OpenSearch, we recommend placing synonyms in a file on the Elasticsearch or OpenSearch server (in the `config` directory). This allows you to reload synonyms without reindexing.
  380 +For Elasticsearch 7.3+ or OpenSearch, we recommend placing synonyms in a file on the Elasticsearch or OpenSearch server (in the `config` directory). This allows you to reload synonyms without reindexing.
381 381  
382 382 ```txt
383 383 pop, soda
... ... @@ -387,22 +387,18 @@ burger, hamburger
387 387 Then use:
388 388  
389 389 ```ruby
390   -search_synonyms: "synonyms.txt"
391   -```
392   -
393   -For Elasticsearch, add [elasticsearch-xpack](https://github.com/elastic/elasticsearch-ruby/tree/master/elasticsearch-xpack) to your Gemfile:
394   -
395   -```ruby
396   -gem 'elasticsearch-xpack', '>= 7.8', '< 7.14'
  390 +class Product < ApplicationRecord
  391 + searchkick search_synonyms: "synonyms.txt"
  392 +end
397 393 ```
398 394  
399   -Reload with:
  395 +And reload with:
400 396  
401 397 ```ruby
402 398 Product.search_index.reload_synonyms
403 399 ```
404 400  
405   -#### Elasticsearch < 7.3 or OpenSearch
  401 +#### Elasticsearch < 7.3
406 402  
407 403 You can use a library like [ActsAsTaggableOn](https://github.com/mbleigh/acts-as-taggable-on) and do:
408 404  
... ...
gemfiles/activerecord50.gemfile
... ... @@ -9,7 +9,6 @@ gem &quot;activerecord&quot;, &quot;~&gt; 5.0.0&quot;
9 9 gem "actionpack", "~> 5.0.0"
10 10 gem "activejob", "~> 5.0.0", require: "active_job"
11 11 gem "elasticsearch", "~> 6"
12   -gem "elasticsearch-xpack", "~> 6"
13 12 gem "redis"
14 13 gem "connection_pool"
15 14 gem "kaminari"
... ...
gemfiles/activerecord51.gemfile
... ... @@ -9,7 +9,6 @@ gem &quot;activerecord&quot;, &quot;~&gt; 5.1.0&quot;
9 9 gem "actionpack", "~> 5.1.0"
10 10 gem "activejob", "~> 5.1.0", require: "active_job"
11 11 gem "elasticsearch", "~> 6"
12   -gem "elasticsearch-xpack", "~> 6"
13 12 gem "redis"
14 13 gem "connection_pool"
15 14 gem "kaminari"
... ...
gemfiles/activerecord52.gemfile
... ... @@ -9,7 +9,6 @@ gem &quot;activerecord&quot;, &quot;~&gt; 5.2.0&quot;
9 9 gem "actionpack", "~> 5.2.0"
10 10 gem "activejob", "~> 5.2.0", require: "active_job"
11 11 gem "elasticsearch", "~> 7"
12   -gem "elasticsearch-xpack", ">= 7.8", "< 7.14"
13 12 gem "redis"
14 13 gem "connection_pool"
15 14 gem "kaminari"
... ...
gemfiles/activerecord60.gemfile
... ... @@ -9,7 +9,6 @@ gem &quot;activerecord&quot;, &quot;~&gt; 6.0.0&quot;
9 9 gem "actionpack", "~> 6.0.0"
10 10 gem "activejob", "~> 6.0.0", require: "active_job"
11 11 gem "elasticsearch", "~> 7"
12   -gem "elasticsearch-xpack", ">= 7.8", "< 7.14"
13 12 gem "redis"
14 13 gem "connection_pool"
15 14 gem "kaminari"
... ...
gemfiles/activerecord70.gemfile
... ... @@ -9,7 +9,6 @@ gem &quot;activerecord&quot;, &quot;~&gt; 7.0.0.alpha2&quot;
9 9 gem "actionpack", "~> 7.0.0.alpha2"
10 10 gem "activejob", "~> 7.0.0.alpha2", require: "active_job"
11 11 gem "elasticsearch", "~> 7"
12   -gem "elasticsearch-xpack", ">= 7.8", "< 7.14"
13 12 gem "redis"
14 13 gem "connection_pool"
15 14 gem "kaminari"
... ...
gemfiles/mongoid6.gemfile
... ... @@ -8,7 +8,6 @@ gem &quot;mongoid&quot;, &quot;~&gt; 6.0.0&quot;
8 8 gem "activejob", require: "active_job"
9 9 gem "redis"
10 10 gem "elasticsearch", "~> 7"
11   -gem "elasticsearch-xpack", ">= 7.8", "< 7.14"
12 11 gem "actionpack"
13 12 gem "kaminari"
14 13 gem "gemoji-parser"
... ...
gemfiles/mongoid7.gemfile
... ... @@ -8,7 +8,6 @@ gem &quot;mongoid&quot;, &quot;~&gt; 7.0.0&quot;
8 8 gem "activejob", require: "active_job"
9 9 gem "redis"
10 10 gem "elasticsearch", "~> 7"
11   -gem "elasticsearch-xpack", ">= 7.8", "< 7.14"
12 11 gem "actionpack"
13 12 gem "kaminari"
14 13 gem "gemoji-parser"
... ...
lib/searchkick/index.rb
... ... @@ -183,11 +183,9 @@ module Searchkick
183 183 if Searchkick.opensearch?
184 184 client.transport.perform_request "POST", "_plugins/_refresh_search_analyzers/#{CGI.escape(name)}"
185 185 else
186   - require "elasticsearch/xpack"
187 186 raise Error, "Requires Elasticsearch 7.3+" if Searchkick.server_below?("7.3.0")
188   - raise Error, "Requires elasticsearch-xpack 7.8+" unless client.xpack.respond_to?(:indices)
189 187 begin
190   - client.xpack.indices.reload_search_analyzers(index: name)
  188 + client.transport.perform_request("GET", "#{CGI.escape(name)}/_reload_search_analyzers")
191 189 rescue Elasticsearch::Transport::Transport::Errors::MethodNotAllowed
192 190 raise Error, "Requires non-OSS version of Elasticsearch"
193 191 end
... ...