Reputation: 8512
Is there any way to determine on runtime if a model should be indexed or not? Something like:
class Article < ActiveRecord::Base
searchable :if => :indexable? do
...
end
private
def indexable?
...
end
end
Upvotes: 4
Views: 1059
Reputation: 1305
Here's a good article on conditional indexing: http://mikepackdev.com/blog_posts/19-conditional-indexing-with-sunspot
That is, exactly the API you propose in your question.
Upvotes: 2
Reputation: 3069
Answered here
Exclude draft articles from Solr index with Sunspot
Upvotes: 5