coreseek版本:Coreseek 3.2.14
1.配置文件csft_mysql.conf
#源定义
source xgn
{
type = mysql
sql_host = localhost
sql_user = root
sql_pass =
sql_db = xgn
sql_port = 3306
sql_query_pre = SET NAMES utf8
sql_query_pre = replace into sph_counter select 1,max(id) from buyer_info
sql_query_range = select 1,max(id) from buyer_info
sql_range_step = 1000
sql_query = SELECT id, qq, qtname,address FROM buyer_info where id>=$start and id <=$end and id <=(select max_doc_id from sph_counter where counter_id=1)
#sql_query第一列id需为整数
#title、info作为字符串/文本字段,被全文索引
sql_query_info = SELECT * FROM buyer_info WHERE id=$id #命令行查询时,从数据库读取原始数据信息
}
source delta : xgn
{
sql_query_pre = SET NAMES utf8
sql_query = SELECT id, qq, qtname,address FROM buyer_info where id>=$start and id <=$end and id <=(select max_doc_id from sph_counter where counter_id=1)
sql_query_post_index = replace into sph_counter select 1,max(id) from buyer_info
}
#index定义
index xgn
{
source = xgn #对应的source名称
path = D:/coreseek/var/data/xgn
docinfo = extern
mlock = 0
morphology = none
min_word_len = 1
html_strip = 0
#charset_dictpath = /usr/local/mmseg3/etc/ #BSD、Linux环境下设置,/符号结尾
charset_dictpath = D:/coreseek/etc/ #Windows环境下设置,/符号结尾
charset_type = zh_cn.utf-8
}
index delta : xgn
{
source = delta
path = D:/coreseek/var/data/mysqlInfoSPHDelta
}
#全局index定义
indexer
{
mem_limit = 128M
}
#searchd服务定义
searchd
{
listen = 9312
read_timeout = 5
max_children = 30
max_matches = 1000
seamless_rotate = 0
preopen_indexes = 0
unlink_old = 1
pid_file = D:/coreseek/var/log/searchd_mysql.pid
log = D:/coreseek/var/log/searchd_mysql.log
query_log = D:/coreseek/var/log/query_mysql.log
}
2.先在mysql中插入一个计数表
CREATE TABLE sph_counter(
counter_id INTEGER PRIMARY KEY NOT NULL,
max_doc_id INTEGER NOT NULL
);
3.创建主索引
D:\coreseek\bin\indexer -c D:\coreseek\etc\csft_mysql.conf xgn
4.启动守护进程
D:\coreseek\bin\searchd --install --config d:/coreseek/etc/csft_mysql.conf
5.添加记录
6.更新增量索引,这个写在.bat文件里,用windows设置定时任务,每分钟执行。
文件名:build_delta_index.bat
内容:
D:
D:\coreseek\bin\indexer -c D:\coreseek\etc\csft_mysql.conf delta --rotate
7.合并索引,这个也要写在脚本里,每天合并一次
文件名:build_main_index.bat
内容:
D:
D:\coreseek\bin\indexer -c D:\coreseek\etc\csft_mysql.conf --merge xgn delta --rotate --merge-dst-range deleted 0 0 --rotate //合并索引
D:\mysql-5.6.23-win32\mysql-5.6.23-win32\bin\mysql -hlocalhost -uroot -p -xgn -e 'REPLACE INTO sph_counter SELECT 1, MAX(id) FROM buyer_info' //更改maxid
D:\coreseek\bin\indexer -c D:\coreseek\etc\csft_mysql.conf delta --rotate>>D:\coreseek\var\log\deltaindexlog//重建增量索引