Prevent indexing of some models with Tire in a Rails application

I have an item search model in my Rails application.

I want to index most of them in ElasticSearch, EXCEPT those that fulfill some condition.

How can i do this?

Overrides update_index in model acceptable solution?


I know that I could also index them all and filter in the search. But they will never be searchable, so I see no reason to index them at all.

+4
source share
1 answer

The simplest thing is to handle the indexing binding as specified in README :

Please note that you can skip, including the Tire :: Model :: Callbacks module, in special cases, for example, when your records are indexed through some external mechanism (...) or when you need to better control how documents are added or removed from index:

 class Article < ActiveRecord::Base include Tire::Model::Search after_save do update_index if state == 'published' end end 
+7
source

All Articles