Reputation: 3383
I have pushed my app to heroku, and I'm having functionality issues with my search features. I'm using ElasticSearch with Tire, as well as the Bonsai addon for Heroku. I've created a bonsai.rb initializer per the documentation for Bonsai: https://devcenter.heroku.com/articles/bonsai#installing-the-add-on
It looks like this so far:
ENV['ELASTICSEARCH_URL'] = ENV['BONSAI_URL']
Here's the error I'm getting from Heroku logs when I try to run a search:
Tire::Search::SearchRequestFailed (404 : {"error":"Index not found, and lazy index creation is disabled.
I had thought that Tire would create indexes automatically. To be honest, I'm a little unclear about what these indexes are. Are they the same as the indexes in my development database? Is anyone aware of a good guide or tutorial for deploying an app with these features? Thanks in advance!
Upvotes: 1
Views: 969
Reputation: 5095
Ooh, how cool - I get to actually be the first person to answer a question. So I think the underlying problem is that while Tire does create indexes automatically, it doesn't do so in the production environment. If you follow the instructions on the Heroku page on Bonsai, your production index will be named differently than your development index. So your production index won't contain documents, because it hasn't been set up already by Tire.
The solution, which worked for me, is described on Config Tire to work with Bonsai ElasticSearch Heroku add-on:
heroku run rake environment tire:import CLASS=School FORCE=true
The value of the CLASS
variable would be the name of your model, of course, not School
.
To answer your second question - "what these indexes are" - they are search indexes, which function similarly to database indexes, but
That's a very high level summary of what "search indexes" are - start here on this Wikipedia article on search indexing to learn all about the wonderful world of unstructured full-text search!
Upvotes: 1