无法读取 searchd 响应

发布于 2024-12-04 23:17:15 字数 1800 浏览 4 评论 0原文

我在 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);

?>

关于原因的任何想法问题出在哪里?

I Got this error in Sphinx.

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

PHP file >> i am fallowing this 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);

?>

Any idea about the cause of the problem ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

梦情居士 2024-12-11 23:17:15

我也有同样的问题。

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

    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

I had the same problem.

In my config file I was:

    listen             = 127.0.0.1:9312:mysql41

I had to add another listener on a different port

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

and then in PHP:

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

Don't forget to restart sphinx searchd:

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

and

/usr/local/sphinx/bin/searchd -c /usr/local/sphinx/etc/sphinx.conf
玩物 2024-12-11 23:17:15

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

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

change port number to whatever in your sphinx.conf file. if your sphinx daemon listening to 9312 change in your code as follows

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

堇年纸鸢 2024-12-11 23:17:15

你真的在运行 Sphinx 守护进程吗?您需要运行如下所示的命令:(

searchd --config sphinx.conf

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

Are you actually running the Sphinx daemon? You'll need to run something like this:

searchd --config sphinx.conf

(And to stop it, just add --stop to the end of that).

伴梦长久 2024-12-11 23:17:15

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

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

我也缺少“WHERE 1”的含义;

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

You can't intermix SphinxQL and API. You search query is full SphinxQL query that should be queried via php_mysql and to query via API ypu should use change to

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

I also missing the meaning of "WHERE 1";

And API and SphinxQL should be mapped to different ports.

不醒的梦 2024-12-11 23:17:15

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

Have a look at the bug report here. The problem exists in the PHP API when reading the data from the sphinx server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文