如何在新的Nitrous.io IDE上设置SearchKick / ElasticSearch?

时间:2015-07-17 13:52:09

标签: ruby-on-rails ruby elasticsearch nitrousio searchkick

我正在关注McKenzie Childs关于在Ruby on Rails上制作“Movie Review”应用程序的教程,他正在使用searchkick gem。我正在通过新的Nitrous平台做一切,一切都让人困惑。

我正在运行此命令:

rake searchkick:reindex CLASS=Movie 

并在shell中出现以下错误:

rake aborted!
Faraday::ConnectionFailed: Connection refused - connect(2) for "localhost"port 9200
/home/nitrous/code/12_in_12/movie_review/.bundle/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:80:in `perform_request'
/home/nitrous/code/12_in_12/movie_review/.bundle/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:40:in `block in call'
/home/nitrous/code/12_in_12/movie_review/.bundle/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:87:in `with_net_http_connection'
/home/nitrous/code/12_in_12/movie_review/.bundle/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:32:in `call'
/home/nitrous/code/12_in_12/movie_review/.bundle/gems/faraday-0.9.1/lib/faraday/rack_builder.rb:139:in `build_response'
/home/nitrous/code/12_in_12/movie_review/.bundle/gems/faraday-0.9.1/lib/faraday/connection.rb:377:in `run_request'
/home/nitrous/code/12_in_12/movie_review/.bundle/gems/elasticsearch-transport-1.0.12/lib/elasticsearch/transport/transport/http/faraday.rb:21:in `block in perform_request'
/home/nitrous/code/12_in_12/movie_review/.bundle/gems/elasticsearch-transport-1.0.12/lib/elasticsearch/transport/transport/base.rb:190:in `call'

Errno::ECONNREFUSED: Connection refused - connect(2) for "localhost" port 9200
/home/nitrous/code/12_in_12/movie_review/.bundle/gems/faraday-0.9.1/lib/faraday/adapter/net_http.rb:80:in `perform_request'

我觉得它有关于连接端口或启动某个服务器的问题。这是新的Nitrous Web IDE的第一个月。

1 个答案:

答案 0 :(得分:6)

昨天的教程是否遇到了同样的问题(使用的是cloud9 IDE)。我注意到我收到了这个错误,因为弹性搜索没有运行。我使用命令

卸载了它

sudo apt-get --purge autoremove elasticsearch

然后重新安装。

wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.7.0.deb
sudo dpkg -i elasticsearch-1.7.0.deb

#enable on bootup
sudo update-rc.d elasticsearch defaults 95 10

### Start ElasticSearch 
sudo /etc/init.d/elasticsearch start

### Make sure service is running
curl http://localhost:9200

### Should return something like this:
# {
#  "status" : 200,
#  "name" : "Storm",
#  "version" : {
#    "number" : "1.3.1",
#    "build_hash" : "2de6dc5268c32fb49b205233c138d93aaf772015",
#    "build_timestamp" : "2014-07-28T14:45:15Z",
#    "build_snapshot" : false,
#    "lucene_version" : "4.9"
#  },
#  "tagline" : "You Know, for Search"
#}

Searchkick在此之后工作。在安装弹性搜索之前,您应该安装java。希望这可以帮助你