I have an indexed model called Article and I don\'t want solr to index unpublished articles.
class Article < ActiveRecord::Base
searchable do
text :
If you want to make sure unpublished articles are never included in the search index, you can do it this way instead:
class Article < ActiveRecord::Base
searchable :if => :published? do
text :title
text :body
end
end
The model will then only be indexed when published.
My approach is less interesting if you also want admins to be able to search for articles, including unpublished ones, however.
Note: calling article.index!
will add the instance to the index regardless of the :if => :method
param.