Last active
February 1, 2017 20:03
Revisions
-
somazx revised this gist
Dec 12, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ # config/initializers/elasticsearch.rb # ensure you set AWS_ES_URL, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY # change region as needed require 'patron' require 'faraday_middleware/aws_signers_v4' -
somazx created this gist
Dec 12, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ gem 'elasticsearch', '>= 1.0.15' gem 'elasticsearch-model' gem 'elasticsearch-rails' gem 'patron' gem 'faraday_middleware-aws-signers-v4' gem 'searchkick' This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ # config/initializers/elasticsearch.rb # ensure you set AWS_ES_URL, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY require 'patron' require 'faraday_middleware/aws_signers_v4' # arguably this should be defined elsewhere class AmazonElasticSearchClient def self.client return Elasticsearch::Client.new(url: ENV['AWS_ES_URL']) do |f| f.request :aws_signers_v4, credentials: Aws::Credentials.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']), service_name: 'es', region: 'us-west-2' end end end # for local development I run a local elasticsearch, # so I only override the Searchkick.client in production environments Searchkick.client = AmazonElasticSearchClient.client if Rails.env.production?