找不到匹配的php / sphinx

时间:2017-12-04 12:45:42

标签: php mysql sphinx

我有一个县表,其中包含county_name,state_name等列。我想对这两列应用AND条件以获得结果。我已将此表编入索引,现在尝试在我的php代码中获取结果,如下所示

$county = "Clarke County";
$state = "AL";

$result = $cl->query("@county_name $county @state_name $state", 'indexername');

// $result = $cl->RunQueries();
print_r($result);

if ( $result === false ) {
      echo "Query failed: " . $cl->GetLastError() . ".\n";
}
else {
      if ( $cl->GetLastWarning() ) {
          echo "WARNING: " . $cl->GetLastWarning() . "<br>";
      }

           // print_r($result['1']['matches']);
          foreach ($result as $key => $value) {
            if (!empty($result[$key]['matches'])) {
                foreach ($result[$key]['matches'] as $doc_id => $val) {
                    $a = $val['attrs'];
                    echo $a['county_name']." : ".$a['state_name']." : ".$a['prefix']."\n";
                  // callToFetchNearbyPlaces($a['prefix']);
                  // break;
                }
                } else {
                     echo 'No results found';        
                }
          }
}

但是,我的输出低于输出而没有匹配。

Array
(
    [error] => 
    [warning] => 
    [status] => 0
    [fields] => Array
        (
            [0] => county_name
            [1] => state_name
            [2] => state_code
            [3] => prefix
        )

    [attrs] => Array
        (
            [county_name] => 7
            [state_name] => 7
            [prefix] => 7
        )

    [total] => 0
    [total_found] => 0
    [time] => 0.000
    [words] => Array
        (
            [clark] => Array
                (
                    [docs] => 18
                    [hits] => 18
                )

            [counti] => Array
                (
                    [docs] => 3048
                    [hits] => 3048
                )

            [al] => Array
                (
                    [docs] => 67
                    [hits] => 67
                )

        )

)

理想情况下,它应该将县名称为“克拉克县”并命名为“AL”。

0 个答案:

没有答案