doushi7394 2016-06-23 17:47
浏览 96

Sphinx结果不会在空格后返回匹配

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.

  • 写回答

1条回答 默认 最新

  • dstt1818 2016-06-23 18:05
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式