Aaron Holdsworth
Aaron Holdsworth

Reputation: 1

Shpinx results not returning matches after spaces

When trying to do a search for bmw motorrad or partials of it.

bmw is ok

bmw m or any characters after return no results

bmw motorrad returns the company

We finally got a chance to move our servers from managed to self managed. in the process we upgraded mysql from 5.0.37 to 5.5.28.

We also upgraded sphinx from 0.9.9 to 2.2.10 with Sphinx as a mysql engine. We are using Laravel 5.1 and using a package sngrl\SphinxSearch to connect to sphinx.

Shpinx Conf:

Start Company Quick Search

source companyqs
{
        type                    =       mysql
        sql_query_pre           =       SET NAMES utf8
        sql_query               =       SELECT c.companyID, c.companyID AS priID , TRIM(REPLACE(c.coName, SUBSTRING(c.coName,LOCATE('[',c.coName), (LOCATE(']',c.coName)) - LOCATE('[',c.coName)+1), '')) AS companyName FROM company c WHERE c.coType = "Corporate" AND companyID >= $start AND companyID <= $end

        sql_attr_uint           =       priID
        sql_field_string        =       companyName
        sql_attr_string         =       cityState
        sql_attr_string         =       locationType
        sql_attr_string         =       cWebDisplay

}

index companyqs
{
        source                  =       companyqs
        path                    =       /usr/local/sphinx/var/data/companyqs
        min_word_len            =       2
        min_infix_len           =       1
}

config for sngrl\SphinxSearch

return array (
'host'    => env('SPHINX_DEV_HOST'),
'port'    => 9312,
'indexes' => array (
    'companyqs' => array ( 'table' => 'company', 'column' => 'companyID' ),
)

);

sphinxSearch search query

public function getQSAdvertiser($keyword){
    $sphinx = new SphinxSearch();
    $results = $sphinx
        ->search($keyword, 'companyqs')
        ->limit(10000)
        ->setMatchMode(\Sphinx\SphinxClient::SPH_MATCH_EXTENDED2)
        ->setRankingMode(\Sphinx\SphinxClient::SPH_RANK_MATCHANY)
        ->query();

    return $results;
}

Thanks for looking and appreciate any help.

Upvotes: 0

Views: 62

Answers (1)

barryhunter
barryhunter

Reputation: 21091

You may need to change min_word_len to 1 to get single char matches.

But also 0.9 to 2.2 is a big jump! A number of defaults have changed. Mainly I think that old version may of had enable_star=0 as the default.

enable_star has been abolished as an option (and is effectively =1 always now)

So you need to add stars. Could do this in code. Change the query to 'bmw m*'

However there is expand_keywords=1 which gives you similar (but not identical) behaviour, will change rank slightly. That in theory would need no other code changes.

Upvotes: 0

Related Questions