简体   繁体   中英

How to setup elasticsearch on Heroku?

I've implemented elasticsearch/searchkick on my app and it works on development. My resources for the elasticsearch/searchkick implementation is GoRails and I installed elasticsearch successfully. But when I pushed it on Heroku, it gave me the error:

"We're sorry, but something went wrong."

I did heroku logs and the errors are:

"Completed 500 Internal Server Error in 16ms (Searchkick: 8.0ms | ActiveRecord: 0.0ms)"

and

"Faraday::ConnectionFailed (Connection refused - connect(2) for "localhost" port 9200):"

Please try this .................

Searchkick uses ENV["ELASTICSEARCH_URL"] for the Elasticsearch server. This defaults to http://localhost:9200.
Heroku

Choose an add-on: SearchBox, Bonsai, or Elastic Cloud.

# SearchBox

heroku addons:create searchbox:starter
heroku config:set ELASTICSEARCH_URL=`heroku config:get SEARCHBOX_URL`

# Bonsai

heroku addons:create bonsai
heroku config:set ELASTICSEARCH_URL=`heroku config:get BONSAI_URL`

# Found

heroku addons:create foundelasticsearch
heroku config:set ELASTICSEARCH_URL=`heroku config:get FOUNDELASTICSEARCH_URL`

Then deploy and reindex:

heroku run rake searchkick:reindex CLASS=Product

Please refer this documentation https://github.com/ankane/searchkick#deployment for more information. Hope this will work for you. Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM