2011-04-25 35 views
2

我是狮身人面像的新手。狮身人面像完美匹配问题?

<?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模式。但它不起作用?

回答

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; ?> 
+0

如果您正在使用某种形式的词干,您也会得到一个“一个男孩”的匹配。我认为... – Rafa 2011-08-23 13:20:14