Last active
April 12, 2018 21:22
-
-
Save diegoy/1c0e93adcfcd559faaba823a5bf3c7eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializer/elasticsearch.rb | |
config = { | |
transport_options: { request: { timeout: 5 } } | |
} | |
if File.exist?('config/elasticsearch.yml') | |
template = ERB.new(File.new('config/elasticsearch.yml').read) | |
processed = YAML.safe_load(template.result(binding)) | |
config.merge!(processed[Rails.env].symbolize_keys) | |
end | |
# if you choose to use elasticsearch-rails-model | |
Elasticsearch::Model.client = Elasticsearch::Client.new(config) | |
# if you choose to use elasticsearch-rails-persistence | |
Elasticsearch::Persistence.client = Elasticsearch::Client.new(config) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment