ThinkingSphinx 不接受条件
我无法让 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 }
不幸的是,无论如何
总是返回一个空数组。 为什么?
I'm having trouble getting ThinkingSphinx to recognize my conditions.
My Discussion model includes the following code:
define_index do
indexes [subject, body], :as => :text
indexes replies.body, :as => :reply_text
set_property :delta => true
end
And as expected this search
Discussion.search "handy"
returns any discussion with the word "handy" in its subject, body, or the body of one of its replies.
Now I'm implementing a "deleting posts" feature, and I want to show only discussions where the field called :disabled == false.
Unfortunately, this search:
Discussion.search "handy", :conditions => { :disabled => false }
always returns an empty array, no matter what.
Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在
define_index
块中定义一个属性disabled
:完成此操作后,停止 Sphinx,重新索引并重新启动,希望它应该工作。
You'll need to have an attribute
disabled
defined in yourdefine_index
block:Once you've done this, stop Sphinx, re-index, and restart, and hopefully it should work.