我一直在试图通过PHP使用狮身人面像,到目前为止,我已经绝对没有运气。狮身人面像php api不工作
狮身人面像本身如预期的那样发挥作用(通过Linux终端我的搜索命令工作)
的Engine_Api_SphinxClient是狮身人面像常规PHP API附带的安装包。唯一的区别是该类的命名。
// Connect to sphinx server
$sp = new \Engine_Api_SphinxClient();
// Set the server
$sp->SetServer('localhost', 9312);
// SPH_MATCH_ALL will match all words in the search term
$sp->SetMatchMode(SPH_MATCH_ANY);
// We want an array with complete per match information including the document ids
$sp->SetArrayResult(true);
$sp->setFieldWeights(array(
'thesis'=>2,
'body'=>1
));
/**
* Run the search query. Here the first argument is the search term
* and the second is the name of the index to search in.
* Search term can come from a search form
*/
$results = $sp->Query('gun', 'test1');
debug($results);
该setServer中的9312是在sphinx配置文件中定义的监听文章。 调试行给出“假”,我看到下面的警告和注意事项:
Errors
Warning: Invalid argument supplied for foreach() in /library/Engine/Api/SphinxClient.php on line 998
Warning: assert(): Assertion failed in /library/Engine/Api/SphinxClient.php on line 177
Warning: assert(): Assertion failed in /library/Engine/Api/SphinxClient.php on line 177
Warning: Invalid argument supplied for foreach() in /library/Engine/Api/SphinxClient.php on line 1006
Warning: Invalid argument supplied for foreach() in /library/Engine/Api/SphinxClient.php on line 1054
Warning: Invalid argument supplied for foreach() in /library/Engine/Api/SphinxClient.php on line 1070
Notice: Undefined property: Engine_Api_SphinxClient::$_socket in /library/Engine/Api/SphinxClient.php on line 564
Notice: Undefined property: Engine_Api_SphinxClient::$_socket in /library/Engine/Api/SphinxClient.php on line 569
Notice: Undefined property: Engine_Api_SphinxClient::$_socket in /library/Engine/Api/SphinxClient.php on line 477
Notice: Undefined property: Engine_Api_SphinxClient::$_socket in /library/Engine/Api/SphinxClient.php on line 478
Warning: fclose() expects parameter 1 to be resource, null given in /library/Engine/Api/SphinxClient.php on line 478
我怀疑是它有事情做与这四个通知。如果任何人都可以提供什么问题的暗示,那将不胜感激。
什么在线上的SphinxClient.php?什么断言失败? – Tchoupi 2012-08-14 00:59:54
该行上的代码是:'code'assert(is_numeric($ v));'code'。 $ v是刚刚传入函数的参数。第177行是该函数的第一行。好吧,无论如何,这些代码可以在互联网上免费下载,如果您有兴趣,可以下载它。 – Furyvore 2012-08-14 17:15:36