For Tire (ElasticSearch wrapper gem), how do you query and filter out indexed records that has nil/null value for a certain attribute. For example, if I have this relationship
class Article < ActiveRecord::Base
belongs_to :topic
end
I have article indexed but I want to avoid pulling back records with topic_id = nil. I tried this code blow but it didn't work.
class Article
belongs_to :topic
def search(q)
tire.search do
...
filter :missing, :field => :topic_id, { :existence => false, :null_value => false }
...
### filter :range, :topic_id => { :gt => 0 } # ==> I tried this as well but didn't work
...
end
end
end