Where clause has OR In Sphinx

痴心易碎 提交于 2019-12-11 04:43:33

问题


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?


回答1:


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)



来源:https://stackoverflow.com/questions/38333103/where-clause-has-or-in-sphinx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!