开发者

Sphinx returning inconsistent results when searched through command line vs. using php api

I am making a boolean query i.e. "hello | world" . when I make this query through the command line, it gives correct results i.e. the documents which contain both of these terms are shown on the top and the ones containing only one of them are shown in the bottom.

However, when I make the same query from php api of sphinx, it gives wrong results. I am making the query from command line using:

C:\sphinx-1.10\bin\search --config C:\sphinx-1.10\sphinx.conf.in "hello | world" --limit 3

This returns the correct results now, the php code I am using is:

<?php


include('/sphinx-1.10/api/sphinxapi.php');

  $cl = new SphinxClient();
  $cl->SetMatchMode(SPH_MATCH_BOOLEAN);
  $cl->SetSortMo开发者_如何学Gode(SPH_SORT_RELEVANCE);
  $cl->SetLimits(0,3);

  $result = $cl->Query( "hello | world", 'sample' );

  if ( $result === false ) {
      echo "Query failed: " . $cl->GetLastError() . "<br/>";
  }
  else {
      if ( $cl->GetLastWarning() ) {
          echo "WARNING: " . $cl->GetLastWarning() . "<br/>";
      }
      if ( ! empty($result["matches"]) ) {
          foreach ( $result["matches"] as $doc => $docinfo ) {
                echo "$doc <br/>";
          }
      }
  }
?>

The above returns wrong results.

Can someone please guide me with what am I doing wrong??


Have you tried with SPH_MATCH_EXTENDED2 matching mode instead? Perhaps it's the boolean mode that does the damage http://sphinxsearch.com/docs/current.html#boolean-syntax

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜