开发者

Thinking Sphinx: is it possible to use complex logic with attributes?

开发者 https://www.devze.com 2023-01-12 05:03 出处:网络
This question is in a way related to this other question: Sphinx Filters - Can I have an 'OR' between filters attributes?

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? Ba开发者_运维百科sically, 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.


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]) ) =>

Model.search "((@attribute_a 1) | (attribute_a 0 (attribute_b x|y|z) ) )",:match_mode => :extended

0

精彩评论

暂无评论...
验证码 换一张
取 消