user5250856
user5250856

Reputation:

Where clause has OR In Sphinx

Is there a way to do this line in sphinx search

where field_a = 'Value' or field_b = 'Value'

I have tried so far

$sphinx->where(field_A | field_B, '=', 'Value')

But it's not working. Could someone help me to get over this?

Upvotes: 1

Views: 716

Answers (1)

barryhunter
barryhunter

Reputation: 21091

Sphinx itself does not support 'OR' in the WHERE clause.

But can do something like

SELECT id, (attribute_a = 'Value' OR attribute_b = 'Value') AS test
FROM index
WHERE test = 1

It's a little convoluted, but does work. Also no idea what library you using to build the query, so left as an exercise to how to construct a SQL query like above.

(Also note I changed to call the column, attributes instead. Sphinx treats attributes and fields very differently. Clarifying this is a way of filtering attributes)

Upvotes: 3

Related Questions