当我通过控制台搜索时,sphinx正常工作:
index 'dreamsIndex': query 'demo': returned 2 matches of 2 total in 0.017 sec
displaying matches:
1. document=494, weight=1620
2. document=495, weight=1620
words:
1. 'd500': 2 documents, 2 hits
但是当我通过php api进行相同的搜索时,我没有得到任何结果。实际上,$result['total_found']
的值为2,但$result['matches']
为空。
include_once('sphinxapi.php');
$sphinx = new SphinxClient();
$sphinx->SetServer("localhost", 9312);
$sphinx->SetConnectTimeout(1);
$sphinx->SetArrayResult(true);
$sphinx->SetMatchMode(SPH_MATCH_ANY);
$sphinx->SetSortMode(SPH_SORT_RELEVANCE)
$result = $sphinx->Query("demo","*");
if ($result===false) echo "Error: ".$sphinx->GetLastError();
else {
if ($sphinx->GetLastWarning()) echo "Warning: ".$sphinx->GetLastWarning();
echo "Total found: ".$result['total_found']."\r\n";
if (sizeof($result['matches'])) {
foreach ($result['matches'] as $val) {
echo "id = ".$val['attrs']['id']."\r\n";
}
}
}
实际上$result['matches']
甚至不存在。有$result['attrs']
,但它是空的。
Here is how $result
looks like (link)
我很困惑。