Thinking Sphinx:是否可以使用具有属性的复杂逻辑?
这个问题在某种程度上与另一个问题相关: Sphinx 过滤器 - 我可以在过滤器属性之间使用“OR”吗?
在我看来,sphinx 现在支持 OR 逻辑来过滤属性,但无法通过思考 sphinx 来使用该功能。
在Think Sphinx中是否可以使用任何复杂的逻辑来过滤属性?基本上,我想做的是在搜索中指定属性的条件,例如:a OR ((NOT a) AND b)
,我会像这样使用它:
( (attribute_a == true) OR (attribute_a == false AND attribute_b IN [x,y,z]) )
或类似的内容。问题是 :with 和 :without 都期望哈希并用 AND (或 AND NOT)连接每个条件,如果我没有记错的话。
This question is in a way related to this other question: Sphinx Filters - Can I have an 'OR' between filters attributes?
It seems to me that sphinx now has support for OR logic to filter with attributes, but there is no way to use that feature through thinking sphinx.
Is it possible to use any complex logic to filter with attributes in thinking sphinx? Basically, what I'm trying to do is specify conditions on attributes in my search, for example something like: a OR ((NOT a) AND b)
, I would use it like so:
( (attribute_a == true) OR (attribute_a == false AND attribute_b IN [x,y,z]) )
Or something similar to that. The problem is that both :with and :without expect a hash and join each condition with an AND (or AND NOT), if I'm not mistaken.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗨索伦利
您可能可以使用类似这样的
Model.search "(@field_name1 value1 | value2) (@field_name2 value3 | value4),:match_mode => :extended
Here '|' space 等于 and。
等于 or by sphinx且
=>
Hi Sorenly
You can probably use something like this
Model.search "(@field_name1 value1 | value2) (@field_name2 value3 | value4),:match_mode => :extended
Here '|' is equated to or by sphinx and space is equated to an and.
( (attribute_a == true) OR (attribute_a == false AND attribute_b IN [x,y,z]) )
=>