tags:

views:

102

answers:

1

I have this sphinx search engine that I use through Zend using sphinxapi.php . It works fantastic. Really really great.

However, there is one problem: It randomly fails.

   // Prepare Sphinx search
   $sphinxClient = new SphinxClient();
   $sphinxClient->SetServer($ip, $port);
 $sphinxClient->SetConnectTimeout( 10 );

   $sphinxClient->SetMatchMode( SPH_MATCH_ANY  );
   $sphinxClient->SetLimits( $resultsPerPage * ($nPage - 1), $resultsPerPage );
 $sphinxClient->SetArrayResult( true );

 $query = array();
 $query['lang'] = '@lang "lang' . $language . '"';

 if (isset($params)) {
        foreach ($params as $param) {
   $query['tags'] = '@tags "' . $param . '"';
        }
 }

 // Make the Sphinx search
 $sphinxClient->SetMatchMode(SPH_MATCH_EXTENDED);
 $sphinxResult = $sphinxClient->Query(implode(' ', $query), '*');

As seen here, I search for a language and an arbitrary amount of tags, imploded into a single query string in the end (instead of making a battleload of subqueries).

So, normally, this works like a charm, but occassionally sphinx returns that it found 2000 entries in English and, say, 1000 entries with the tag "pictures" (or some other purely english word) but ZERO hits that fit both results, which is purely false. In fact, refreshing the page everything returns to normal with something like 800 real results.

My question is why does it do this and how do I make it stop?

Any ideas?

:Edit: Added shortened output log

    [error] => 
    [warning] => 
...
    [total] => 0 
    [total_found] => 0 
    [time] => 0.000 
    [words] => Array ( 
     [langen] => Array ( 
      [docs] => 2700 
      [hits] => 2701 ) 
     [picture] => Array ( 
      [docs] => 829 
      [hits] => 1571 ) ) )
A: 

have you checked to see if the sphinx client is giving you any error or warning messages that may describe the failure?

if($sphinxResult === false) {
    print "Query failed: " . $sphinxClient->GetLastError();
} else {
    if($sphinxClient->GetLastWarning()) {
        print "WARNING: " . $sphinxClient->GetLastWarning();
    }

    // process results
}
Ty W
Just added the error dropouts from a typical failed query. As you see, it doesn't give me an error and is actually very successful in finding all hits in english AND pictures, but for whatever reason failing to combine them.
John
what version are you running? if it's the latest (0.9.9-rc2) you could try using the SPH_MATCH_EXTENDED2 matching mode to see if it is any more reliable... though I doubt this is truly the issue.
Ty W
Hello, tried the extended 2, but to no avail. Still happens randomly, so I don't know what to do.
John