ThinkingSphinx不接受条件
-
03-07-2019 - |
题
我无法让ThinkingSphinx认出我的情况。
我的讨论模型包括以下代码:
define_index do
indexes [subject, body], :as => :text
indexes replies.body, :as => :reply_text
set_property :delta => true
end
正如预期的那样搜索
Discussion.search "handy"
返回任何带有“handy”字样的讨论。在其主题,正文或其中一个回复的正文中。
现在我正在实施“删除帖子”功能,我想只显示字段调用的讨论:disabled == false。
不幸的是,这次搜索:
Discussion.search "handy", :conditions => { :disabled => false }
总是返回一个空数组,无论如何。
为什么?
解决方案
您需要在 define_index
块中定义 disabled
属性:
define_index do
indexes [subject, body], :as => :text
indexes replies.body, :as => :reply_text
has disabled
set_property :delta => true
end
完成此操作后,停止Sphinx,重新编制索引并重新启动,希望它能够正常工作。
不隶属于 StackOverflow