RailsCasts Pro episodes are now free!
Learn more or hide this
There is a newer version of this episode, see the revised episode.
Resources
script/plugin install git://github.com/freelancing-god/thinking-sphinx.git rake thinking_sphinx:index rake thinking_sphinx:start
define_index do indexes content indexes :name, :sortable => true indexes comments.content, :as => :comment_content indexes [author.first_name, author.last_name], :as => :author_name has author_id, created_at end
@articles = Article.search params[:search] # :include => :author # :conditions => { :created_at => 1.week.ago.to_i..Time.now.to_i } # :order => :name # :field_weights => { :name => 20, :content => 10, :author_name => 5 } # :match_mode => :boolean # :page => 1, :per_page => 20
Full Source Code