0

I can use pipes in side the MATCH in SphinxQl e.g.

Select * from idx_A where MATCH('(@(Title) Apple)|(@(Body) Orange)')

but not outside the match

Select * from idx_A where MATCH('(@(Title) Apple)|(@(Body) Orange)') and Title='Apple' or Body='Orange'

as I get an error similar to:

[Err] 1064 - sphinxql: syntax error, unexpected OR, expecting $end near 'or Body='Orange`

Am I using incorrect syntax outside of the MATCH() or is it not possible to construct here using 'OR'?

user3649739
  • 1,829
  • 2
  • 18
  • 28
  • No, can't use OR in the 'WHERE'. See http://stackoverflow.com/questions/31199579/how-to-write-sphinx-queries-with-or-condition and http://stackoverflow.com/questions/38333103/where-clause-has-or-in-sphinx for some suggestions – barryhunter Feb 09 '17 at 13:46
  • @barryhunter @BarryHunter Thanks the IN I've used already for this but it only applies to single field e.g. `userID in (1,2,3)`. In my case I am trying to mix two different fields e.g. `userid in (1,2,3) OR productid in (1,2,3)`. I tried initially doing those inside match eg. `(@(userid) 1|2|3)|(@(productid) 1|2|3)` which naturally does work yet the whole reason I moved to the `in` outside of `Match` is I had a large set of values for both fields and MATCH was both a) slower and b) failed so I was forced to move large OR pipes outside of it. I will give your `Virtual Attribute` some thought – user3649739 Feb 10 '17 at 14:47

0 Answers0