Commit fd71344152dad5ae59498cbc298cf4bf62ffc846
1 parent
66c4f40c
Exists in
master
and in
2 other branches
Removed elasticsearch-xpack dependency for reloadable synonyms
Showing
11 changed files
with
9 additions
and
22 deletions
Show diff stats
CHANGELOG.md
Gemfile
README.md
... | ... | @@ -375,9 +375,9 @@ search_synonyms: ["lightbulb => halogenlamp"] |
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 "activerecord", "~> 5.0.0" |
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 "activerecord", "~> 5.1.0" |
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 "activerecord", "~> 5.2.0" |
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 "activerecord", "~> 6.0.0" |
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 "activerecord", "~> 7.0.0.alpha2" |
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
gemfiles/mongoid7.gemfile
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 | ... | ... |