0

所以我有一个 rails 3.2 应用程序。我创建了一个索引。我按照本指南:https : //gist.github.com/nz/2041121 创建了一个 bonsai.rb 文件,config/initializers/bonsai.rb 如下所示:

ENV['ELASTICSEARCH_URL'] = ENV['BONSAI_URL']

# Optional, but recommended: use a single index per application per environment.
# Caveat: This convention not be entirely supported throughout Tire's API.
app_name = Rails.application.class.parent_name.underscore.dasherize
app_env = Rails.env
INDEX_NAME = "#{app_name}-#{app_env}"

但是我没有工作,这是heroku日志的输出:

2013-03-06T17:04:54+00:00 app[web.1]: Processing by SchoolsController#index as HTML
2013-03-06T17:04:54+00:00 app[web.1]: Started GET "/trafikskola?utf8=%E2%9C%93&query=Malm%C3%B6" for 192.165.96.102 at 2013-03-06 17:04:54 +0000
2013-03-06T17:04:54+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "query"=>"Malmö"}
2013-03-06T17:04:58+00:00 heroku[router]: at=info method=GET path=/trafikskola?utf8=%E2%9C%93&query=Malm%C3%B6 host=stormy-escarpment-2346.herokuapp.com fwd="192.165.96.102" dyno=web.1 queue=0 wait=0ms connect=1ms service=3106ms status=500 bytes=643
2013-03-06T17:04:58+00:00 app[web.1]:
2013-03-06T17:04:58+00:00 app[web.1]:   app/models/school.rb:19:in `search'
2013-03-06T17:04:58+00:00 app[web.1]:   app/controllers/schools_controller.rb:10:in `index'
2013-03-06T17:04:58+00:00 app[web.1]: Completed 500 Internal Server Error in 3073ms
2013-03-06T17:04:58+00:00 app[web.1]: Errno::ECONNREFUSED (Connection refused - connect(2)):
2013-03-06T17:04:58+00:00 app[web.1]:
2013-03-06T17:04:58+00:00 app[web.1]: 

我的问题:

  1. 我应该ELASTICSEARCH_URL在 bonsai.rb 文件中放一些东西吗?如果是,那是什么?
  2. 我已经创建了一个本地索引,这是否意味着什么?
  3. 或者是别的什么?
4

1 回答 1

1

config/initializers/bonsai.rb是正确的,问题是我也必须在生产模式下对其进行索引。

所以我这样做了:

heroku rake environment tire:import CLASS=School FORCE=true

它奏效了。

于 2013-03-06T18:02:05.943 回答