ankane/searchkick — pull request #77 by jtomaszewski (2013-12-21 17:13:50+00:00)
Title: Index only some models, not #all

What if I would want to index only some models from all in my table?

I noticed that I could set the `#search_import` method to be something like `scope :search_import, -> { where(type: 'visible') }`.

Unfortunately in my situation, I can't get the answer `should_index?` by scope query, but I have to do some inner calculations in model method.

Currently I am using this hack below:
```ruby
def self.search_import
relation = Object.new
class << relation
attr_accessor :items

def find_in_batches
items.find_in_batches do |batch|
yield batch.select{ |item| item.should_index? }
end
end
end
relation.items = self.includes([:user])
relation
end
```

but obviously it's not really readable. We could easily add some `should_index?` method in https://github.com/ankane/searchkick/blob/master/lib/searchkick/reindex.rb and make it return true as default.

Would be that okay? I can do it on my own and send you a PR, of course.