Coreseek全文索引配置及使用

Coreseek 是一款中文全文检索/搜索软件…(详情请见http://www.coreseek.cn

$ wget http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.14.tar.gz
$ tar -zxvf coreseek-3.2.14.tar.gz

#安装mmseg
$ cd mmseg-3.2.14
$ ./bootstrap    #输出的warning信息可以忽略,如果出现error则需要解决
$ ./configure --prefix=/usr/local/mmseg3
$ make && make install
$ cd ..

#安装coreseek
$ cd coreseek-3.2.14
$ ./configure --prefix=/usr/local/sphinx --with-mysql --with-mmseg-includes=/usr/local/mmseg/include/mmseg --with-mmseg-libs=/usr/local/mmseg/lib/
$ make && make install

#把字典文件和mmseg.ini配置文件拷贝到相应的目录
$ cp uni.lib /usr/local/sphinx/dict/uni.lib
$ cp mmseg.ini/usr/local/sphinx/dict/mmseg.ini

#修改配置文件mmseg.ini和csft.conf
$ vim mmseg.ini
merge_number_and_ascii=1;
number_and_ascii_joint=-;
compress_space=0;
seperate_number_ascii=1;
#merge_number_and_ascii: 字母和数字连续出现是非切分 #number_and_ascii_joint:连接数字和字母可用的符号,如'-' '.' 等
#compress_space:暂时无效
#seperate_number_ascii:是否拆分数字,如 1988 -> 1/x 9/x 8/x 8/

$ vim csft.conf
source src1
{
        type = mysql  

        sql_host = localhost
        sql_user = root
        sql_pass = 123456
        sql_db = dbTest
        sql_port = 3306  # optional, default is 3306  

        sql_query = select id, content, addtime, reason, flag from tbLog  

        sql_attr_uint = id
        sql_attr_timestamp = addtime

        sql_query_info = SELECT * FROM tbLog WHERE id=$id
}

index test1
{
        source = src1
        path = /data/sphinx/data
        docinfo = extern
        charset_type = sbcs
        charset_dictpath = /usr/local/sphinx/dict
}  

indexer
{
        mem_limit = 32M
}  

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

#生成index
$ /usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/csft.conf --all

#启动daemon
$ /usr/local/sphinx/bin/searchd --config /usr/local/sphinx/etc/csft.conf

#关闭服务
$ /usr/local/sphinx/bin/searchd --config /usr/local/sphinx/etc/csft.conf --stop

#启动之后如果更新索引要加rotate参数
#/usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/csft.conf --all --rotate

#测试
$ /usr/local/sphinx/bin/search 'test'

发表评论