Sunday, February 5, 2012

Query Clause "OR", "AND" in Sphinx Search Engine


sometimes we want to sphinx to search in specific index like address and state, but sometimes we want to make it's like mysql query who support "or", "and" clause.

it's many ways to do that, but i wanna share simple one (for me it's simple one :D)

hmm.. i use sphinx 1.10. and without bullshit it's the sample code you can use for "or", "and" cluase:

$results = $sc->Query('@title  javascript & @city newyork | @country "united state");

just like that, it's simple right :D just use " | " for "or" and "&" for "and".

$sc in there is variable you use for define sphinx api in your code..

hope it's usefull for you :D