我是Sphinx的新手。
<?php
include('sphinxapi.php');
$cl = new SphinxClient();
$cl->SetServer('localhost',9312);
//$cl->SetMatchMode(SPH_MATCH_ANY);
//$cl->SetMatchMode(SPH_MATCH_EXTENDED2);
//$cl->SetMatchMode(SPH_MATCH_ALL);
$cl->SetMatchMode(SPH_MATCH_PHRASE);
$cl->SetArrayResult(true);
$cl->SetLimits(0, 100);
$result = $cl->Query("&name one boy","abc_index");
echo "<pre>";
print_r($result);
exit;
?>
我只需要“one boy
”字匹配记录匹配模式是否正确?
我已经在使用SPH_MATCH_PHRASE
模式了。但它不起作用?
答案 0 :(得分:3)
<?php
include('sphinxapi.php');
$cl = new SphinxClient();
$cl->SetServer('localhost',9312);
$cl->SetMatchMode(SPH_MATCH_EXTENDED2);
$cl->SetArrayResult(true);
$cl->SetLimits(0, 100);
//this is for perfect match mode
$searchkey='one boy';
$sphinxQry = '@(name) '. '"'.$searchkey.'"';
$result = $cl->Query($sphinxQry,"abc_index");
echo "<pre>";
print_r($result);
exit; ?>