search for a phrase in Sphinx

147 views Asked by At

I'm not able to search for a phrase in Sphinx 2.2.9 using extended syntax. In PHP, for example, I'd like use a code that sounds like this:

<?php
    require ("sphinxapi.php");
    $cl = new SphinxClient ();
    $cl->setServer("127.0.0.1", 9312);
    // $cl->SetMatchMode (SPH_MATCH_PHRASE); CAN'T USE! DEPRECATED IN VERSION 2.2.9
    $MORETHANAWORD = "to be or not to be";

    // some smart code...

    echo "Ok, in your " . $docs . " docs the phrase " . $MORETHANAWORD . " is present " . $hits . "times.";     
?>
1

There are 1 answers

0
barryhunter On
$res = $cl->Query("\"$MORETHANAWORD\"", 'index_name');
$docs = $res['total_found'];

Can't get $hits. Sphinx doesnt tell you how many times the phrase occurs (in cases its in a document multiple times) - just the number of matching documents.