K
K
Khurshed Abdujalil2017-04-07 08:28:06
Sphinx
Khurshed Abdujalil, 2017-04-07 08:28:06

How to fix sphinx yii2 error?

SQLSTATE[42000]: Syntax error or access violation: 1064 sphinxql: syntax error, unexpected QUOTED_STRING, expecting CONST_INT or CONST_FLOAT or '-' near ''58e7208978321a11f339cbb2''
The SQL being executed was: SELECT * FROM `real_index` WHERE `product_id` ='58e7208978321a11f339cbb2'' it
seems that the product_id is specified as a string in the config, but it requires it to be a number, what's wrong?
The sampling is done like this

$product = (new Query())->select('*')
            ->from('real_index')
            ->andWhere(['product_id' => (string)$model->_id])
            ->one();

ps When inserting any field into andWhere there will be a similar error
sphinx config
index real_index
{
    type = rt
    path = /var/sphinx/real_index_rt

    rt_field = key
    rt_field = product_id
    rt_field = product_name
    rt_field = description
    rt_field = company
    rt_attr_string = key
    rt_attr_string = product_id 
    rt_attr_string = product_name
    rt_attr_string = description

    charset_table = 0..9, A..Z->a..z, _, a..z, \
            U+410..U+42F->U+430..U+44F, U+430..U+44F, \
            U+5d0..U+5ea, U+5f0..U+5f2, \
            U+621..U+63a, U+640..U+64a, U+66e..U+66f, U+671..U+6d3, U+6d5, \
            U+6e5..U+6e6, U+6ee..U+6ef, U+6fa..U+6fc, U+6ff, \
            U+e01..U+e30, U+e32..U+e33, U+e40..U+e46

    morphology = stem_enru
    rt_mem_limit = 1024M
}

index real_category_index
{
    type = rt
    path = /var/sphinx/real_category_index_rt

    rt_field = category_id
    rt_field = category_name
    rt_attr_string = category_id
    rt_attr_string = category_name

    charset_table = 0..9, A..Z->a..z, _, a..z, \
            U+410..U+42F->U+430..U+44F, U+430..U+44F, \
            U+5d0..U+5ea, U+5f0..U+5f2, \
            U+621..U+63a, U+640..U+64a, U+66e..U+66f, U+671..U+6d3, U+6d5, \
            U+6e5..U+6e6, U+6ee..U+6ef, U+6fa..U+6fc, U+6ff, \
            U+e01..U+e30, U+e32..U+e33, U+e40..U+e46

    morphology = stem_enru
    rt_mem_limit = 1024M
}

index real_location_index
{
    type = rt
    path = /var/sphinx/real_location_index_rt

    rt_field = location_id
    rt_field = location_name
    rt_attr_string = location_id
    rt_attr_string = location_name

    charset_table = 0..9, A..Z->a..z, _, a..z, \
            U+410..U+42F->U+430..U+44F, U+430..U+44F, \
            U+5d0..U+5ea, U+5f0..U+5f2, \
            U+621..U+63a, U+640..U+64a, U+66e..U+66f, U+671..U+6d3, U+6d5, \
            U+6e5..U+6e6, U+6ee..U+6ef, U+6fa..U+6fc, U+6ff, \
            U+e01..U+e30, U+e32..U+e33, U+e40..U+e46

    morphology = stem_enru
    rt_mem_limit = 1024M
}


searchd
{
    listen              = 9312:mysql41
    log                 = /var/log/sphinxsearch/searchd.log
    query_log           = /var/log/sphinxsearch/query.log
    pid_file            = /run/sphinxsearch/searchd.pid
    max_children        = 10
    read_timeout        = 10
    workers             = threads
    binlog_path         = /var/log/sphinxsearch
    rt_flush_period     = 3600
    expansion_limit     = 540
compat_sphinxql_magics = 0

}

indexer
{
    mem_limit = 256M
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Хуршед Абдужалил, 2017-04-10
@akhur

проблему решил, установил более свежую версию, и запросы выполняются корректно

Дмитрий, 2017-04-07
@slo_nik Куратор тега Yii

Доброе утро.
Syntax error or access violation: 1064 sphinxql: syntax error, unexpected QUOTED_STRING, expecting CONST_INT or CONST_FLOAT or '-' near ''58e7208978321a11f339cbb2''
если по нашему, то
Синтаксическая ошибка или нарушение прав доступа: 1064 sphinxql: ошибка синтаксиса, неожиданный QUOTED_STRING, ожидая const_int или CONST_FLOAT или «-» рядом «» 58e7208978321a11f339cbb2 «»
Проверяйте сам запрос, всё ли корректно у Вас написано, подставлено и закрыто?
P.S.
Блин!
А зачем Вы andWhere втулили?
Сначала where, а потом, если требуется добавить условие - andWhere
Сейчас у Вас запрос выглядит примерно так:
А это ошибка, которую Вы видите при попытке выполнить запрос.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question