问题
I'm using sphinx to list me some items from my database here.
It's almost 100%, I just haven't figured out yet how to create an OR
between two different filters. For example:
My Object in the database has a starting and an ending date, I can filter(starting_date, x, y)
and filter(ending_date,x,y)
, but both filters will have to return true to bring me the object, how can I say to sphinx filter this attribute, or that one?
回答1:
Sphinx uses | for or
as in "black" OR "white" would be "black" | "white" http://www.sphinxsearch.com/docs/manual-0.9.9.html#boolean-syntax
回答2:
Asked and answered on the Sphinx Forums.
Only possible in 0.9.9, using the SetSelect.
http://sphinxsearch.com/forum/view.html?id=3577
回答3:
There is no way of having OR
logic across different attributes in Sphinx. Normally, there's two possible work-arounds:
- Have one multi-value attribute with both sets of values you want to match against - and filter on arrays of values.
- If it's the same OR logic every time, combine it into a single boolean attribute, having the SQL statement do the initial hard work.
Using timestamps makes things a bit more difficult though - MVAs are only for integers at this point... are you after all objects that are occuring at a specific time? Or something else?
来源:https://stackoverflow.com/questions/869733/sphinx-filters-can-i-have-an-or-between-filters-attributes