狮身人面像完美匹配问题?

时间:2011-04-25 04:46:46

标签: php sphinx

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

1 个答案:

答案 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; ?>