【问题标题】:failed to read searchd response未能读取 searchd 响应
【发布时间】:2011-09-15 18:37:48
【问题描述】:

我在 Sphinx 中遇到了这个错误。

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

PHP 文件 >> 我正在闲置这个tutorial

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

?>

知道问题的原因吗?

【问题讨论】:

    标签: php search sphinx


    【解决方案1】:

    我遇到了同样的问题。

    在我的配置文件中,我是:

        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 searchd:

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

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

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        【解决方案3】:

        你真的在运行 Sphinx 守护进程吗?你需要运行这样的东西:

        searchd --config sphinx.conf
        

        (要停止它,只需在其末尾添加 --stop 即可)。

        【讨论】:

          【解决方案4】:

          您不能混合使用 SphinxQL 和 API。您的搜索查询是完整的 SphinxQL 查询,应通过 php_mysql 查询并通过 API 查询 ypu 应使用更改为

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

          我也错过了“WHERE 1”的意思;

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

          【讨论】:

            【解决方案5】:

            查看错误报告here。从sphinx服务器读取数据时,PHP API存在问题。

            【讨论】:

              猜你喜欢
              • 2014-06-13
              • 2020-12-08
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2013-03-11
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多