我在 Sphinx 中遇到了这个错误。
{"status":"failed","status_message":"failed to read searchd response (status=2613, ver=11829, len=774975488, read=66)"}
Run Code Online (Sandbox Code Playgroud)
PHP 文件>> 我正在学习本教程
<?php
require_once('sphinxapi.php');
$sphinxClient = new SphinxClient();
$sphinxClient->SetServer( 'localhost', 3306 );
$sphinxClient->SetConnectTimeout( 1 );
$sphinxClient->SetFieldWeights(array('title' => 70, 'body_text' => 30));
$sphinxClient->SetMatchMode( SPH_MATCH_EXTENDED2 );
$sphinxClient->SetLimits( 0, 20, 1000 );
$sphinxClient->SetRankingMode( SPH_RANK_PROXIMITY_BM25 );
$sphinxClient->SetArrayResult( true );
$searchQuery = "SELECT title FROM `documents` WHERE 1";
$searchResults = $sphinxClient->Query( $searchQuery, '*' );
$jhash = array();
if ( $searchResults === false )
{
$jhash['status'] = 'failed';
$jhash['status_message'] = $sphinxClient->GetLastError();
}
else
{
if ( $sphinxClient->GetLastWarning() )
{
$jhash['status'] = 'warning';
$jhash['status_message'] = $sphinxClient->GetLastWarning();
}
else
{
$jhash['status'] = 'good';
}
$jhash['result_total'] = $searchResults['total'];
$jhash['result_found'] = $searchResults['total_found'];
$jhash_matches = array();
if ( is_array($searchResults["matches"]) )
{
$row_ids = array();
foreach ( $searchResults["matches"] as $docinfo )
{
array_push($row_ids, mysql_real_escape_string($docinfo['id']));
}
}
$jhash['matches'] = $jhash_matches;
}
echo json_encode($jhash);
?>
Run Code Online (Sandbox Code Playgroud)
知道问题的原因吗?
我有同样的问题。
在我的配置文件中,我是:
listen = 127.0.0.1:9312:mysql41
Run Code Online (Sandbox Code Playgroud)
我不得不在不同的端口上添加另一个侦听器
listen = 127.0.0.1:9312:mysql41
listen = 127.0.0.1:9313
Run Code Online (Sandbox Code Playgroud)
然后在 PHP 中:
$sphinxsearch->SetServer( 'localhost', 9313 );
Run Code Online (Sandbox Code Playgroud)
不要忘记重新启动 sphinx searchd:
/usr/local/sphinx/bin/searchd --stop
Run Code Online (Sandbox Code Playgroud)
和
/usr/local/sphinx/bin/searchd -c /usr/local/sphinx/etc/sphinx.conf
Run Code Online (Sandbox Code Playgroud)