我有一个索引,我想根据某些条件对某些属性进行过滤。
下面的结构运行正常
Class A
attr_accessible :vaild_date
belongs_to: B
define_index 'index_for_a' do
indexes ...
...
has B.C.plant_id, :as => :plant_id
end
end
class B
has_many: C
end
class C
attr_accessible :plant_id,:month_timestamps
end
现在我的C类有很多行。我只想为其中的行设置plant_id
C.month_timestamps = A.valid_date
请提出一些实现此目标的方法。对think_sphinx来说是新手,所以我无法正确使用条件和子句。
添加一个
#Assuming Class C is stored in db as Cs
where "Cs.month_timestamps = valid_date"
这样到你的define_index
街区
define_index 'index_for_a' do
indexes ...
...
has B.C.plant_id, :as => :plant_id
join B.C
#Assuming Class C is stored in db as Cs
where "Cs.month_timestamps = valid_date"
end
更新
更新
尝试这样的事情
has "IFNULL(Cs.plant_id,0)", :as => :plant_id
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句