sqlsphinxsql-likesphinxql

SphinxQL request similar to LIKE in SQL


I was wondered I got the different results of the following requests:

SphinxQL:

SELECT ticket_id FROM message WHERE MATCH('*test*') LIMIT 0, 100000 OPTION max_matches = 100000

Result was 221 rows

SQL:

SELECT * FROM `ticket_logs` WHERE message LIKE '%test%'

Result was 321 rows

What should the SphinxQL request be to get the same result as SQL-request (321 rows).

BTW: The code of Sphinx index is the next:

source ticket_logs
{
    type            = mysql
    sql_host        = localhost
    sql_user        = root
    sql_pass        = 
    sql_db          = test_db
    sql_port        = 3306
    sql_query_pre   = SET NAMES utf8
}

source messages : ticket_logs
{   
    sql_query = \
        SELECT id, ticket_id, message FROM ticket_logs

    sql_field_string = ticket_id
    sql_field_string = message
}

index message
{
    source          = messages
    path            = c:/sphinx/data/index/message
}

searchd
{
    listen          = 9306:mysql41
    pid_file        = c:/sphinx/data/searchd.pid
    log             = c:/sphinx/data/log/searchd.log
    query_log       = c:/sphinx/data/log/query.log
    binlog_path     = c:/sphinx/data/binlog/
}

Solution

  • You dont appear to have min_infix_len defined in your config

    http://sphinxsearch.com/docs/current.html#conf-min-infix-len

    ... you need it to explicitly enable 'wildcard' queries.

    That will give you much closer results.