Sphinx Filters - Can I have an 'OR' between filters attributes?

徘徊边缘 提交于 2019-12-07 23:49:16

问题


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:

  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?



来源:https://stackoverflow.com/questions/869733/sphinx-filters-can-i-have-an-or-between-filters-attributes

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