如何在 Heroku 上设置弹性搜索?

How to setup elasticsearch on Heroku?

我已经在我的应用程序上实现了 elasticsearch/searchkick,它正在开发中。我用于 elasticsearch/searchkick 实现的资源是 GoRails,我成功安装了 elasticsearch。但是当我把它推到 Heroku 上时,它给了我错误:

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

我做了 heroku 日志,错误是:

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

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

请试试这个.................

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

选择一个插件:SearchBox、Bonsai 或 Elastic Cloud。

#搜索框

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

#盆景

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

#找到

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

然后部署并重建索引:

heroku run rake searchkick:reindex CLASS=Product

请参阅此文档 https://github.com/ankane/searchkick#deployment 了解更多信息。 希望这对你有用。谢谢!