对于轮胎(ElasticSearch 包装器 gem),您如何查询和过滤出某个属性具有 nil/null 值的索引记录。例如,如果我有这种关系
class Article < ActiveRecord::Base
belongs_to :topic
end
我已将文章编入索引,但我想避免使用topic_id = nil拉回记录。我尝试了这段代码,但没有奏效。
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