For the past 4 weeks I've been fighting a loosing battle with Bonsai and Elasticsearch, which in someways is disheartening because a few months ago I had it working on another app.
My app is crashed, when I go to Heroku I just get the "Application Error" warning. When I checkout the Herkou Logs
I find something that I believe to be the problem:
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)>'
Specifically this line:
import': professors does not exist to be imported into. Use create_index! or the :force option to create it. (ArgumentError)
Everything works fine on Localhost but it crashes with Heroku. I found this question which I think is similar to mine and one of the answers said to try:
$ 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
But whenever I run a rails console in Heroku heroku run rails console
I get pretty much the same error:
/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'
Just use Service.import(force: true)
to import data.
If index already exists, it will delete index and re-create it before import data.
If index not exists, it will create index and import data directly.
so no need Service.__elasticsearch__.create_index!
anymore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With