jeudi 23 juin 2016

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.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire