Skip to content

Instantly share code, notes, and snippets.

@dinks
Forked from nz/configuring tire for bonsai.md
Created December 11, 2012 13:08
Show Gist options
  • Save dinks/4258438 to your computer and use it in GitHub Desktop.
Save dinks/4258438 to your computer and use it in GitHub Desktop.
Configuring Tire to work with Bonsai

1. Configure Tire to use the Bonsai ElasticSearch Heroku add-on

gem 'tire'

config/initializers/bonsai.rb

ENV['ELASTICSEARCH_URL'] = ENV['BONSAI_URL']

# Optional, but recommended: use a single index per application per environment
app_name = Rails.application.class.parent_name.underscore.dasherize
app_env = Rails.env
INDEX_NAME = "#{app_name}-#{app_env}"

app/models/article.rb

class Article
  include Tire::Model::Search
  include Tire::Model::Callbacks
  index_name INDEX_NAME
end

2. Create the index and import your documents

rake environment tire:import CLASS=Article FORCE=true

Known issues

  • Fixed in Bonsai, as of 19Oct12 Custom index analyzers must be set at index creation time. Ability to dynamically create, modify and destroy indexes.
  • Fixed in Tire 0.4.1 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 [] for nil:NilClass on index.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. Issue 386
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment