Exclude draft articles from Solr index with Sunspot
I have an indexed model called Article and I don't want solr to index unpublished articles. class Article < ActiveRecord::Base searchable do text :title text :body end end How can I specify that article that is not #published? should not be indexed? Be sure to index the published status. class Article < ActiveRecord::Base searchable do text :title text :body boolean :is_published, :using => :published? end end Then add a filter to your query Sunspot.search(Article) do |search| search.with(:is_published, true) # ... end If you want to make sure unpublished articles are never included in the