Answer the question
In order to leave comments, you need to log in
SphinxQL how can I improve the quality of the search in 1-2 character values.?
The user enters samsung note in the field,
he is given a list of 7 possible devices.
How to make it index these things Samsung note 10.1 n8020
It finds it on request Samsung note 10., but if you make a request on Samsung note 10.1 it will give the result 0
ps I use asterisks in queries, maybe that's why?
config
source dev_mobile :dev_config {
sql_query = \
SELECT * FROM mobiles
sql_field_string = vendor
sql_field_string = name
}
index dev_mobile
{
source = dev_mobile
path = /var/lib/sphinx/data/dev_mobile
charset_table = 0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F
min_word_len = 1
html_strip = 1
min_infix_len = 3
index_exact_words = 1
blend_chars = &,U+23
morphology = lemmatize_en
#morphology = stem_en
#morphology = stem_enru, soundex, metaphone
}
/**
* Поиск устройства
* @param $query
* @param int $offset
* @param int $limit
* @return array|null
*/
public function searchSphinx($query , $offset = 0, $limit = 30)
{
/**
* @var CDbConnection $sphinx
*/
$sphinx = Yii::app()->sphinx;
$sql = "SELECT id, weight() FROM dev_mobile WHERE MATCH(".$sphinx->quoteValue('@(name,vendor) '.$query.'*').")";
$sql.= " LIMIT $offset,$limit ";
$sql.= " OPTION field_weights=(name=10,vendor=11), max_matches=10000, ranker=expr('sum((4*lcs+2*(min_hit_pos==1)+exact_hit)*user_weight)*1000+bm25');";
$result = $sphinx->createCommand($sql)->queryAll();
$ids = array_map(function($element){return $element['id'];}, $result);
$arr_info = $sphinx->createCommand('show meta')->queryAll();
$data_info = array();
foreach($arr_info as $info)
{
$data_info[ $info['Variable_name'] ] = $info['Value'];
}
if(! count($ids)) return null;
$criteria = new CDbCriteria;
$criteria->condition = 't.id IN('.implode(',',$ids).')';
$criteria->order = 'FIELD(t.id, '.implode(',',$ids).')';
return array(
'data' => self::model()->with('system')->findAll($criteria),
'info' => $data_info
);
}
Answer the question
In order to leave comments, you need to log in
you do not have points in indexed characters, but for some reason you are looking for them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question