Reputation: 929
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.
Upvotes: 0
Views: 496
Reputation: 28
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
Upvotes: 1