aboutsummaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorMax Magorsch <max@magorsch.de>2019-09-05 15:51:34 +0200
committerMax Magorsch <max@magorsch.de>2019-09-05 15:51:34 +0200
commitc62bd4d5644a77d1224f188d092f39e0438062ec (patch)
tree8dc0d218c0dae45add04b1324111318048fa1105 /config
parentAdded docker-compose.override.yml for development purposes (diff)
downloadpackages-5-c62bd4d5644a77d1224f188d092f39e0438062ec.tar.gz
packages-5-c62bd4d5644a77d1224f188d092f39e0438062ec.tar.bz2
packages-5-c62bd4d5644a77d1224f188d092f39e0438062ec.zip
Migrate to ES 7.3 and the repository pattern
Elasticsearch-persistence is used as the persistence layer for Ruby domain objects in Elasticsearch in this application. So far, the ActiveRecord pattern has been used here. However, this pattern has been deprecated as of version 6 of the gem and was removed in version 7. That's why the application has been migrated to use the repository pattern instead. For further information, please see: https://www.elastic.co/blog/activerecord-to-repository-changing- persistence-patterns-with-the-elasticsearch-rails-gem Note: The old Elasticsearch index won't be compatible with this version anymore. That's why a fresh index should be populated. Signed-off-by: Max Magorsch <max@magorsch.de>
Diffstat (limited to 'config')
-rw-r--r--config/initializers/elasticsearch.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/config/initializers/elasticsearch.rb b/config/initializers/elasticsearch.rb
index 4ced5b5..1037b1f 100644
--- a/config/initializers/elasticsearch.rb
+++ b/config/initializers/elasticsearch.rb
@@ -1,9 +1,10 @@
-require 'elasticsearch/persistence/model'
+require 'elasticsearch/persistence'
+
+DEFAULT_CLIENT = Elasticsearch::Client.new host: ENV['ELASTICSEARCH_URL'] || 'localhost:9200'
-Elasticsearch::Persistence.client = Elasticsearch::Client.new host: ENV['ELASTICSEARCH_URL'] || 'localhost:9200'
if Rails.env.development? or ENV['RAILS_DEBUG']
logger = ActiveSupport::Logger.new(STDERR)
logger.level = Logger::DEBUG
logger.formatter = proc { |s, d, p, m| "\e[2m#{m}\n\e[0m" }
- Elasticsearch::Persistence.client.transport.logger = logger
+ DEFAULT_CLIENT.transport.logger = logger
end