I'm trying to setup the new Bonsai ElasticSearch heroku add-on, but until now I can just run the search on my local developement machine, as soon as deployed on Heroku the same search fails silently, or better, Rails logger doesn't log anything while I get a 500 Internal Server Error. This are relevant Heroku logs during the failing query (no evident errors found): https://gist.github.com/2867221
I'm looking for some advices on how troubleshoot that. For example, I set Tire.configure { logger 'elasticsearch.log', :level => 'debug' }
on Bonsai initializer config/initializers/bonsai.rb like the following:
Tire.configure { logger 'elasticsearch.log', :level => 'debug' }
if ENV['BONSAI_INDEX_URL']
Tire.configure do
url "http://index.bonsai.io"
end
BONSAI_INDEX_NAME = ENV['BONSAI_INDEX_URL'][/[^\/]+$/]
else
app_name = Rails.application.class.parent_name.underscore.dasherize
app_env = Rails.env
BONSAI_INDEX_NAME = "#{app_name}-#{app_env}"
end
but it logs on a file, which is good for local but is not accessible after deployed.
Bonsai ElasticSearch is a pritty new on-testing addon, so I wonder if someone of you guys has already had some succesfully experiences deploing that on Heroku and can give me a feedback and some advices.
UPDATE
Setting up logger logger $stdout, :level => 'debug' into Tire.configure finally heroku can log something while it's failing search :
2012-06-04T21:36:26+00:00 heroku[router]: GET gitwatcher.com/categories?utf8=%E2%9C%93&query=Asynchronous+Web+Frameworks dyno=web.1 queue=0 wait=0ms service=32ms status=500 bytes=728
2012-06-04T21:36:26+00:00 heroku[nginx]: 93.34.212.216 - - [04/Jun/2012:21:36:26 +0000] "GET /categories?utf8=%E2%9C%93&query=Asynchronous+Web+Frameworks HTTP/1.1" 500 728 "http://gitwatcher.com/categories" "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:12.0) Gecko/20100101 Firefox/12.0" gitwatcher.com
2012-06-04T21:36:26+00:00 app[web.1]: # 2012-06-04 21:36:26:387 [_search] (["123456789"])
2012-06-04T21:36:26+00:00 app[web.1]: #
2012-06-04T21:36:26+00:00 app[web.1]: curl -X GET "http://index.bonsai.io/123456789/category/_search?load=true&pretty=true" -d '{"query":{"query_string":{"query":"Asynchronous Web Frameworks"}}}'
2012-06-04T21:36:26+00:00 app[web.1]:
2012-06-04T21:36:26+00:00 app[web.1]: # 2012-06-04 21:36:26:387 [200] (1 msec)
2012-06-04T21:36:26+00:00 app[web.1]:
... please see more on issue opened to https://github.com/karmi/tire/issues/365
Just for tracking purposes, I'll report here (cat&past) the resolution I post on GitHub Tire issues:
DEFINETLY WORKS BY:
1) dropping out `to_indexed_json` from Category MongoID model ( at the opposit of README indication )
2) removing and re-adding Bonsai.io Heroku add-on
3) reindexing ElasticSearch by running `heroku run:detached rake environment tire:import CLASS='Category'`
... infact, if you just run rake environment tire:import CLASS='Category' FORCE=true it doesn't work on Heroku/Bonsai.io, becuse of Bonsai authorized operation :
2012-06-11T20:39:30+00:00 app[run.1]: curl -X DELETE http://index.bonsai.io/my-fake-index-11223344
2012-06-11T20:39:30+00:00 app[run.1]: # 2012-06-11 20:39:30:749 [401]
2012-06-11T20:39:30+00:00 app[run.1]: #
2012-06-11T20:39:30+00:00 app[run.1]: # "{\"error\": \"Not authorized: Some endpoints are admin-only, ask [email protected].\"}\n"
than if you want to reset/reindex your eventually dirty data, the only way is dropping the Bonsai add-on and recreate:
heroku addons:remove bonsai:test
heroku addons:add bonsai:test
That saied, I really had a dirty data indicated by :
BSON::InvalidObjectId (illegal ObjectId format: LAm-hNglS5mbrMzDlVVHCQ):
app/controllers/categories_controller.rb:25:in `index'
If you'll need the full gem stack to compare with other cases, here it is: https://gist.github.com/2912881