views:

65

answers:

2

I have used the following code:

   function searchSphinx2($tofind,$jobtype_id,$payper_id,$onetimeBounds)
    {
        $this->load->library('session');
        $this->load->library('sphinxclient');
        global $result;
        global $functionresult;
        $functionresult=array();

        $this->sphinxclient->setServer('localhost', 3312);
        $this->sphinxclient->SetMatchMode( SPH_MATCH_ANY );
        $this->sphinxclient->SetIndexWeights( array("jobs_index_main"=>10, "jobs_index_delta"=>10,"jobs_index_prefix_main"=>1,"jobs_index_prefix_delta"=>1,"jobs_index_infix_main"=>1,"jobs_index_infix_delta"=>1) );

        $this->sphinxclient->ResetFilters();
        $this->sphinxclient->SetFilter('jobtype_id',$jobtype_id,TRUE);
        $this->sphinxclient->SetFilter('payper_id',$payper_id,TRUE);
        $this->sphinxclient->SetFilterFloatRange('payamount', $ontimeBounds[0], $ontimeBounds[1], FALSE);

        $this->sphinxclient->AddQuery("$tofind", "jobs_index_main;jobs_index_delta");
        $this->sphinxclient->AddQuery("*$tofind*", "jobs_index_main_prefix;jobs_index_delta_prefix");
        $this->sphinxclient->AddQuery("*$tofind*", "jobs_index_main_infix;jobs_index_delta_infix");
        $result = $this->sphinxclient->RunQueries();

In my data base there is a job with title "Intern" However, if I search for "inter" I do not get any results.

The indices in my confi file are set up as follows:

index jobs_index_prefix_main
{
        source  = jobs_main
        path = /var/newsphinx/index/main_prefix

        morphology = stem_en
        min_stemming_len = 4
        min_word_len = 3
        min_prefix_len = 3
        prefix_fields = title, contactname
        enable_star =1
}

Can anyone tell me why I am not getting partial word results?

A: 

I've never found Sphinx to return partial matches without using stars. I agree that it's not particularly intuitive (surely if the prefixes are being indexed, there's a match?), but if you want to ensure you always get results, add a star to the end of each word.

pat
A: 

So what I've been passing into the sphinx api "Query" function is the input to a text box. I figured that if i put a star before and after this variable when I pass it into the function and put it in quotes, I'm using the correct syntax. I thought this should give me results if my query matched any part of a word in the prefix or infix indices.

I've been passing my variable, $tofind with a star and quotes on both sides. This is obviously not working.

Is there any way to take a single variable, representing anything from 1 word to a bunch of words separated by spaces, and find partial word results for all of the words?

kevin
This was meant as a comment!
kevin