当我执行以下代码时出现错误。我将 SPhinx 与 PHP 和 MySQL 结合使用。
require ( "sphinxapi.php" );
$cl = new SphinxClient();
$cl->SetServer( "127.0.0.1", 9306 );
$cl->SetMatchMode( SPH_MATCH_ANY );
$cl->SetFilter( 'model', array( 3 ) );
$result = $cl->Query( 'is', 'the' );
if ( $result === false ) {
echo "Query failed: " . $cl->GetLastError() . ".\n";
}
else {
if ( $cl->GetLastWarning() ) {
echo "WARNING: " . $cl->GetLastWarning() . "";
}
if ( ! empty($result["matches"]) ) {
foreach ( $result["matches"] as $doc => $docinfo ) {
echo "$doc\n";
}
print_r( $result );
}
}
exit;
得到这个错误
Deprecated: DEPRECATED: Do not call this method or, even better, use SphinxQL instead of an API in C:\xampp\htdocs\sphinx\sphinxapi.php on line 764
failed to read searchd response (status=2610, ver=11826, len=775040361, read=61).
我正在使用 Wamp 运行 Sphinx。 知道问题的原因吗?
最佳答案
9306端口,通常是sphinx开启sphinxQL监听的端口。
确实建议您应该使用 SphinxQL,而不是 SphinxAPI。不建议使用 SphinxAPI 启动新项目。
没有特殊的客户端可以使用 SphinxQL,您只需使用任何旧的 MySQL 客户端即可。
mysql_* 函数可以工作,或者更好的是 mysqli,甚至是 pdo 等。
关于php - Sphinx 无法读取 searchd 响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23335787/