先配置sphinx

将sphinx.conf-min.dist文件复制为csft.conf

cp /usr/local/coreseek/etc/sphinx.conf.dist /usr/local/coreseek/etc/csft.conf


详细配置如下:

# ----- 主数据源 ----- 

source main
{
    type= mysql
    sql_host= localhost
    sql_user= root
    sql_pass= 123456
    sql_db= test
    sql_port= 3306
    # sql_sock= /tmp/mysql.sock
    sql_query_pre= set names utf8
    sql_query_pre= set SESSION query_cache_type = OFF
    sql_query_pre= replace into sph_counter select 1,max(id) from article
    sql_query= select id,title,season,orderby,atime from product where id <= ( select max_art_id from sph_counter where id = 1 )
    # 排序的东西,返回的结果集中包含下面的字段,可排序
    sql_attr_uint= season
    sql_attr_uint= orderby
    sql_attr_uint= atime
    # 控制台测试语句
    sql_query_info= select id,title from aericle where id=$id
}

# ----- 增量数据源 ----- 

source delta : main{
    sql_query_pre= set names utf8
    sql_query= select id,title from article where id > ( select max_art_id from sph_counter where id = 1)
}


# ----- 主索引 ----- 

index main{
    source= main
    path= /usr/local/coreseek/var/data/main
    charset_type= zh_cn.utf-8
    # 词典位置
    charset_dictpath= /usr/local/mmseg/etc/
}


# ----- 增量索引 ----- 

index delta : main{
    source= delta
    path= /usr/local/coreseek/var/data/delta
}

indexer
{
    mem_limit= 32M
}

searchd
{
    port= 9312
    log= /usr/local/coreseek/var/log/searchd.log
    query_log= /usr/local/coreseek/var/log/query.log
    read_timeout= 5
    max_children= 30
    pid_file= /usr/local/coreseek/var/log/searchd.pid
    max_matches= 1000
    seamless_rotate= 1
    preopen_indexes= 0
    unlink_old= 1
}