Created
August 14, 2012 18:37
-
-
Save joemsak/3351556 to your computer and use it in GitHub Desktop.
Tire, Bonsai Elastic Search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include Tire::Model::Search | |
index_name BONSAI_INDEX_NAME | |
mapping do | |
indexes :id, :index => :not_analyzed | |
indexes :title, :analyzer => 'snowball', :boost => 100 | |
indexes :body, :analyzer => 'snowball' | |
end | |
after_save do | |
update_index unless drafted? || hidden? | |
end | |
after_destroy do | |
update_index | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include Tire::Model::Search | |
include Tire::Model::Callbacks | |
index_name BONSAI_INDEX_NAME | |
mapping do | |
indexes :id, :index => :not_analyzed | |
indexes :title, :analyzer => 'snowball', :boost => 100 | |
indexes :description, :analyzer => 'snowball' | |
indexes :categories, :analyzer => 'snowball', :as => "categories.collect(&:name)" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ENV['BONSAI_INDEX_URL'] | |
Tire.configure do | |
url "http://index.bonsai.io" | |
logger $stdout | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem "tire", "~> 0.4.2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment