【发布时间】:2017-01-08 17:35:51
【问题描述】:
在过去的 4 周里,我一直在与 Bonsai 和 Elasticsearch 进行一场失败的战斗,这在某种程度上令人沮丧,因为几个月前我还在另一个应用程序上使用它。
我的应用程序崩溃了,当我转到 Heroku 时,我只收到“应用程序错误”警告。当我结帐Herkou Logs 时,我发现我认为是问题所在:
2016-08-31T23:23:47.189996+00:00 heroku[web.1]: Process exited with status 1
2016-09-01T00:12:50.088164+00:00 heroku[web.1]: State changed from crashed to starting
2016-09-01T00:12:57.130922+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 14657 -e production`
2016-09-01T00:13:00.947244+00:00 app[web.1]: => Booting WEBrick
2016-09-01T00:13:00.947263+00:00 app[web.1]: => Rails 4.2.5.1 application starting in production on http://0.0.0.0:14657
2016-09-01T00:13:00.947264+00:00 app[web.1]: => Run `rails server -h` for more startup options
2016-09-01T00:13:00.947265+00:00 app[web.1]: => Ctrl-C to shutdown server
2016-09-01T00:13:00.947266+00:00 app[web.1]: Exiting
2016-09-01T00:13:00.947281+00:00 app[web.1]: /app/vendor/bundle/ruby/2.3.0/gems/elasticsearch-model-0.1.9/lib/elasticsearch/model/importing.rb:118:in `import': professors does not exist to be imported into. Use create_index! or the :force option to create it. (ArgumentError)
2016-09-01T00:13:00.947282+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.3.0/gems/elasticsearch-model-0.1.9/lib/elasticsearch/model.rb:116:in `import'
2016-09-01T00:13:00.947283+00:00 app[web.1]: from /app/app/models/professor.rb:31:in `<top (required)>'
特别是这一行:
import': professors does not exist to be imported into. Use create_index! or the :force option to create it. (ArgumentError)
在 Localhost 上一切正常,但在 Heroku 上崩溃了。我找到了this question,我认为它与我的相似,并且其中一个答案说要尝试:
$ rails console
# Create the index for Service model on elasticsearch
> Service.__elasticsearch__.create_index!
=> {"acknowledged"=>true}
# Import current Service records into the index
> Service.import
Service Load (207.3ms) SELECT "services".* FROM "services" ORDER BY "services"."id" ASC LIMIT 1000
# Sample search returning total results
> Service.__elasticsearch__.search("mykeyword").results.total
=> 123
但每当我在 Heroku heroku run rails console 中运行 rails 控制台时,我都会遇到几乎相同的错误:
/app/vendor/bundle/ruby/2.3.0/gems/elasticsearch-model-0.1.9/lib/elasticsearch/model/importing.rb:118:in `import': professors does not exist to be imported into. Use create_index! or the :force option to create it. (ArgumentError)
from /app/vendor/bundle/ruby/2.3.0/gems/elasticsearch-model-0.1.9/lib/elasticsearch/model.rb:116:in `import'
【问题讨论】:
-
男人!检查此answer,它可能会对您有所帮助。祝你好运!
标签: ruby-on-rails heroku