E
E
Evgeniy2020-08-11 19:29:34
Sphinx
Evgeniy, 2020-08-11 19:29:34

Sphinx how to solve search problem?

Hello! faced such a problem.
There is a table id, phrase, intense_key
I try to search for cities, for example:

SELECT *  FROM recognit WHERE MATCH('екатеринбург');
+------+--------------------------+--------------------------+
| id   | phrase                   | intense_key              |
+------+--------------------------+--------------------------+
|   48 | екатеринбург             | екатеринбург             |
+------+--------------------------+--------------------------+
1 row in set (0.00 sec)


If you pass additional word, for example add a city:
SELECT *  FROM recognit WHERE MATCH('город екатеринбург');
Empty set (0.00 sec)


then nothing is found. Actually how to fix it? mysql fulltext handles this scenario correctly.

source ivr
{
    type            = mysql
    sql_host        = localhost
    sql_user        = root
    sql_pass        = pass
    sql_db          = base
    sql_port        = 3306  # optional, default is 3306
    sql_query_pre = SET NAMES utf8
    sql_query_pre = SET CHARACTER SET utf8
    sql_query       =  SELECT id, phrase, intense_key FROM phrases WHERE is_active='yes'
    sql_field_string = phrase
    sql_field_string = intense_key
}
index recognit
{
    source          = ivr
    path            = /var/data/sphinx/recognit
    min_word_len    = 1
    morphology      = stem_ru
    expand_keywords = 1
    min_stemming_len = 1
    min_word_len = 3
    html_strip = 1
    preopen = 1
    min_infix_len = 1
    index_exact_words = 1
}


and just in case show meta;
mysql> show meta;
+---------------+----------------------------+
| Variable_name | Value                      |
+---------------+----------------------------+
| total         | 0                          |
| total_found   | 0                          |
| time          | 0.001                      |
| keyword[0]    | *город*                    |
| docs[0]       | 0                          |
| hits[0]       | 0                          |
| keyword[1]    | *екатеринбург*             |
| docs[1]       | 1                          |
| hits[1]       | 2                          |
| keyword[2]    | =город                     |
| docs[2]       | 0                          |
| hits[2]       | 0                          |
| keyword[3]    | город                      |
| docs[3]       | 0                          |
| hits[3]       | 0                          |
| keyword[4]    | =екатеринбург              |
| docs[4]       | 1                          |
| hits[4]       | 2                          |
| keyword[5]    | екатеринбург               |
| docs[5]       | 1                          |
| hits[5]       | 2                          |
+---------------+----------------------------+
21 rows in set (0.01 sec)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Tikhonov, 2020-08-11
@BoDRbI

SELECT *  FROM recognit WHERE MATCH('город | екатеринбург');

I can’t find it right away in the documentation, but in my opinion, words separated by a space are searched according to the “AND” principle.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question