sphinx增量索引配置

#源定义
source cibn
{   
    type                    = mysql
    sql_host                = localhost
    sql_user                = root
    sql_pass                = 111111
    sql_db                    = test
    sql_port                = 3306

    sql_sock  =  /tmp/mysql.sock #修改路径

    sql_query_pre            = SET NAMES utf8
    sql_query_pre         = REPLACE INTO sph_counter SELECT 3, MAX(id) FROM cibn
    sql_query             = SELECT id,id as xid, search_word FROM cibn
    sql_attr_uint            = xid           #从SQL读取到的值必须为整数
}

#增量索引 源定义
source morecibn:cibn{
    sql_query_pre         = SET NAMES utf8
    sql_query_pre         =
    sql_query             = SELECT id,id as xid, search_word FROM cibn WHERE id>(SELECT max_doc_id FROM sph_counter WHERE counter_id=3)
    sql_query_post_index  = REPLACE INTO sph_counter SELECT 3, MAX(id) FROM cibn
}

#index定义
index cibn_index
{   
    source            = cibn             #对应的source名称
    path            = /cibn #请修改为实际使用的绝对路径,如:/usr/local/coreseek/var/...
    docinfo            = extern
    mlock            = 0
    morphology        = none
    min_word_len        = 1   
    html_strip                = 0

    #中文分词配置,详情请查看:http://www.coreseek.cn/products-install/coreseek_mmseg/
    charset_dictpath = /mmseg/etc/ #BSD、Linux环境下设置,/符号结尾
    #charset_dictpath = etc/                             #Windows环境下设置,/符号结尾,最好给出绝对路径,例如:C:/usr/local/coreseek/etc/...
    charset_type        = zh_cn.utf-8
    #min_prefix_len  =   2
    min_infix_len   =   2
    ngram_len       =   1
}

#增量索引 index定义
index morecibn:cibn_index{
    source          = more
    path            = /morecibn
    docinfo            = extern
    mlock            = 0
    morphology        = none
    min_word_len        = 1
    html_strip                = 0

    #中文分词配置,详情请查看:http://www.coreseek.cn/products-install/coreseek_mmseg/
    charset_dictpath = /mmseg/etc/ #BSD、Linux环境下设置,/符号结尾
    charset_type    = zh_cn.utf-8
    #min_prefix_len  =   2
    min_infix_len   =   2
    ngram_len       =   1
}

脚本 :sphinx 不关闭进程更新索引

#源定义
source cibn
{   
    type                    = mysql
    sql_host                = localhost
    sql_user                = root
    sql_pass                = 111111
    sql_db                    = test
    sql_port                = 3306

    sql_sock  =  /tmp/mysql.sock #修改路径

    sql_query_pre            = SET NAMES utf8
    sql_query_pre         = REPLACE INTO sph_counter SELECT 3, MAX(id) FROM cibn
    sql_query             = SELECT id,id as xid, search_word FROM cibn
    sql_attr_uint            = xid           #从SQL读取到的值必须为整数
}

#增量索引 源定义
source morecibn:cibn{
    sql_query_pre         = SET NAMES utf8
    sql_query_pre         =
    sql_query             = SELECT id,id as xid, search_word FROM cibn WHERE id>(SELECT max_doc_id FROM sph_counter WHERE counter_id=3)
    sql_query_post_index  = REPLACE INTO sph_counter SELECT 3, MAX(id) FROM cibn
}

#index定义
index cibn_index
{   
    source            = cibn             #对应的source名称
    path            = /cibn #请修改为实际使用的绝对路径,如:/usr/local/coreseek/var/...
    docinfo            = extern
    mlock            = 0
    morphology        = none
    min_word_len        = 1   
    html_strip                = 0

    #中文分词配置,详情请查看:http://www.coreseek.cn/products-install/coreseek_mmseg/
    charset_dictpath = /mmseg/etc/ #BSD、Linux环境下设置,/符号结尾
    #charset_dictpath = etc/                             #Windows环境下设置,/符号结尾,最好给出绝对路径,例如:C:/usr/local/coreseek/etc/...
    charset_type        = zh_cn.utf-8
    #min_prefix_len  =   2
    min_infix_len   =   2
    ngram_len       =   1
}

#增量索引 index定义
index morecibn:cibn_index{
    source          = more
    path            = /morecibn
    docinfo            = extern
    mlock            = 0
    morphology        = none
    min_word_len        = 1
    html_strip                = 0

    #中文分词配置,详情请查看:http://www.coreseek.cn/products-install/coreseek_mmseg/
    charset_dictpath = /mmseg/etc/ #BSD、Linux环境下设置,/符号结尾
    charset_type    = zh_cn.utf-8
    #min_prefix_len  =   2
    min_infix_len   =   2
    ngram_len       =   1
}

脚本 :sphinx 不关闭进程更新索引

引用链接

[1] sphinx 不关闭进程更新索引: https://www.wangmaolin.net/books/7f1de/page/sphinx
[2] sphinx 不关闭进程更新索引: https://www.wangmaolin.net/books/7f1de/page/sphinx