Answer the question
In order to leave comments, you need to log in
Why doesn't sphinx search if the phrase consists of more than 2 words?
The extension https://github.com/yiisoft/yii2-sphinx is used .
sphinx config:
source gg : site1
{
sql_query = SELECT id, title, name, address, phone FROM gg__restaurants
sql_attr_uint = id
sql_field_string = title
sql_field_string = name
sql_field_string = address
sql_field_string = phone
}
index siteSearch
{
source = gg
path = /var/www/verygood/data/www/gurman-gid.very-good.ru/sphinx/data/siteSearch
docinfo = extern
dict = keywords
mlock = 0
morphology = stem_enru
expand_keywords = 1
min_stemming_len = 1
min_word_len = 3
html_strip = 1
preopen = 1
min_infix_len = 1
#min_prefix_len = 3
index_exact_words = 1
}
$query = new yii\sphinx\Query();
//$query->select('id, title');
$query->from('siteSearch');
$query->showMeta(true);
$query->match($this->sphinxMatchString($searchString));
$provider = new yii\sphinx\ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSize' => 10,
]
]);
private function sphinxMatchString($query = [])
{
$matchString = [];
foreach ($query as $item) {
$exploded = explode(' ', $item);
foreach ($exploded as $value) {
$matchString[] = $value;
}
}
return '("' . implode('" | "', $matchString) . '")';
}
Answer the question
In order to leave comments, you need to log in
look at the sphinx's qveri log and everything will become clear
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question