views:

927

answers:

3

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?

+2  A: 

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

David Stratton
that works when filtering the attribute value, but i need to filter one attribute or another.
Tiago
A: 

There is no way of having OR logic across different attributes in Sphinx. Normally, there's two possible work-arounds:

  1. Have one multi-value attribute with both sets of values you want to match against - and filter on arrays of values.
  2. 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?

pat
+1  A: 

Asked and answered on the Sphinx Forums.

Only possible in 0.9.9, using the SetSelect.

http://sphinxsearch.com/forum/view.html?id=3577

Ben
Thanks! Your answered saved me lot's of time! I've never thought that you can filter by setselect values
Dienow