简体   繁体   中英

failed to read searchd response

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 ?

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

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

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).

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM