4

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
Vlad Zloteanu
  • 8,464
  • 3
  • 41
  • 58

2 Answers2

5

Answered here

Exclude draft articles from Solr index with Sunspot

Community
  • 1
  • 1
macarthy
  • 3,074
  • 2
  • 23
  • 24
2

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.

Andy Triggs
  • 1,286
  • 12
  • 17