I
I
Igor Karachentsev2016-08-02 15:41:52
Sphinx
Igor Karachentsev, 2016-08-02 15:41:52

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
}

I'm looking like this:
$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,
            ]
        ]);

sphinxMatchString function:
private function sphinxMatchString($query = [])
    {
        $matchString = [];

        foreach ($query as $item) {
            $exploded = explode(' ', $item);
            foreach ($exploded as $value) {
                $matchString[] = $value;
            }
        }

        return '("' . implode('" | "', $matchString) . '")';
    }

As a result, if a search string of one or two words is used, then everything works. Otherwise, it doesn't find anything. Tell me which way to dig? I've been having this problem all day and can't figure out what's going on.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Puma Thailand, 2016-08-02
@kucheriavij

look at the sphinx's qveri log and everything will become clear

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question