读取搜索响应失败


failed to read searchd response

我在Sphinx中得到这个错误。

{"status":"failed","status_message":"failed to read searchd response (status=2613, ver=11829, len=774975488, read=66)"}

>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);
?>

你知道问题的原因吗?

我也遇到了同样的问题。

在我的配置文件中我是:

    listen             = 127.0.0.1:9312:mysql41

我必须在另一个端口上添加另一个侦听器

    listen             = 127.0.0.1:9312:mysql41
    listen             = 127.0.0.1:9313

,然后在PHP中:

$sphinxsearch->SetServer( 'localhost', 9313 );

别忘了重启sphinx search:

/usr/local/sphinx/bin/searchd --stop

/usr/local/sphinx/bin/searchd -c /usr/local/sphinx/etc/sphinx.conf

将端口号更改为sphinx.conf文件中的任何内容。如果您的sphinx守护进程监听9312,在代码中进行如下更改

$sphinxClient->SetServer('localhost', 9312);

您是否正在运行Sphinx守护进程?您需要运行如下命令:

searchd --config sphinx.conf

不能混合使用SphinxQL和API。您的搜索查询是完整的SphinxQL查询,应该通过php_mysql查询,通过API ypu查询应该使用change to

$searchQuery = "";
$searchResults = $sphinxClient->Query( $searchQuery, 'documents' );

我也错过了"WHERE 1"的含义;

API和SphinxQL应该映射到不同的端口

查看这里的bug报告。当从sphinx服务器读取数据时,PHP API存在这个问题。