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//重建增量索引