gem 'tire'
ENV['ELASTICSEARCH_URL'] = ENV['BONSAI_URL']
class Article
include Tire::Model::Search
include Tire::Model::Callbacks
end
rake environment tire:import CLASS=Article FORCE=true
There are no "known issues" with Tire and Bonsai at the moment. Having trouble with something in particular? Drop us a line at [email protected].
Custom index analyzers must be set at index creation time. Ability to dynamically create, modify and destroy indexes.Bulk import uses cluster-level/_bulk
handler rather than the index-level_bulk
handler, causing bulk imports to fail. Issue 327- Multi-model search is not scoped within the index. Issue 322
Undefined method[]
fornil:NilClass
onindex.settings
. Bonsai shared cluster indices are mapped to a random identifier, whereas Tire expects the logical index name in the_index
response. To be fixed within Bonsai. Email [email protected] if this is affecting you. Issue 386ES Alias API not fully supported in Bonsai. Email [email protected] if you would like to beta test that.
so, I followed instructions in the gist, adding this to my initializers/bonsai.rb
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
Also added this to the model
index_name BONSAI_INDEX_NAME
Now, when I run my app locally in development I get the following error
[REQUEST FAILED] curl -X GET "http://localhost:9200/dynamite-urbanite-development/city/_search?load=true&pretty=true" -d '{"query":{"query_string":{"query":"texas","default_operator":"AND"}}}'
Started GET "/cities?utf8=%E2%9C%93&query=texas" for 127.0.0.1 at 2012-07-03 22:12:02 -0400
Connecting to database specified by database.yml
Processing by CitiesController#index as HTML
Parameters: {"utf8"=>"✓", "query"=>"texas"}
Completed 500 Internal Server Error in 3ms
Tire::Search::SearchRequestFailed (404 : {"error":"IndexMissingException[[dynamite-urbanite-development] missing]","status":404}):
app/models/city.rb:20:in
search' app/controllers/cities_controller.rb:3:in
index'