Created
November 29, 2011 09:00
-
-
Save Marchino/1404085 to your computer and use it in GitHub Desktop.
indexing config
This file contains hidden or 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
class Controller < ApplicationController | |
@items = Sunspot.search(ModelName) do | |
fulltext params[:q], :fields => ["description_#{I18n.locale}".to_sym, :author] | |
end | |
end |
This file contains hidden or 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
class ModelName < ActiveRecord::Base | |
searchable :auto_index => false, :auto_remove => false, :if => :is_indexable? do | |
text :author, :stored => true, :boost => 1.0, :more_like_this => true | |
text :description_it, :stored => true, :boost => 1.0, :more_like_this => true do | |
self.whatever_gives_the_italian_description | |
end | |
text :description_en, :stored => true, :boost => 1.0, :more_like_this => true do | |
self.whatever_gives_the_english_description | |
end | |
end |
This file contains hidden or 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
<ul> | |
<% @items.each_hit_with_result do |hit, item| %> | |
<li>Autore: <%= hit.stored(:author) %></li> | |
<li>Descrizione: <%= hit.stored("description_#{I18n.locale}".to_sym) %></li> | |
<% end %> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment