开发者

Complex Query with Sphinx

开发者 https://www.devze.com 2022-12-25 00:19 出处:网络
I am using Sphinx Search. It\'s working fine for me except one problem: I need to exclude some entries where a specific field doesn\'t contain a word.

I am using Sphinx Search. It's working fine for me except one problem: I need to exclude some entries where a specific field doesn't contain a word.

开发者_如何学C

Something that would look like this in MySQL:

SELECT * FROM table
   WHERE yescolumn = 'query' 
   AND othercolumn not like '%keyword%'


You can use Sphinx's extended query syntax to pick the fields you want to search. Try running a query through Sphinx like this:

@yescolumn query @othercolumn -keyword

So in a PHP page you might have a link to a Sphinx database named $sphinx:

$sphinx->SetMatchMode(SPH_MATCH_EXTENDED2);
$results = $sphinx->Query('@yescolumn query @othercolumn -keyword');

More information here: http://www.sphinxsearch.com/docs/current.html#searching

0

精彩评论

暂无评论...
验证码 换一张
取 消