今天在網(wǎng)上找為數(shù)不多的資料,居然找到了一個(gè)比官方手冊機(jī)制策略還好的實(shí)例,是關(guān)于主索引+增量索引,合并索引的文章。趕緊將重點(diǎn)copy過來:
1、sphinx.conf
2、執(zhí)行
./bin/indexer --config /data/opt/sphinx/etc/sphinx.conf dzbbs./bin/indexer --config /data/opt/sphinx/etc/sphinx.conf threads./bin/searchd --config etc/sphinx.conf
3、加入crontab計(jì)劃任務(wù):
# Incremental Index posts data* 0-3 * * * /data/opt/sphinx/bin/indexer --config /data/opt/sphinx/etc/sphinx.conf dzbbs_delta --rotate* 6-23 * * * /data/opt/sphinx/bin/indexer --config /data/opt/sphinx/etc/sphinx.conf dzbbs_delta --rotate0 4 * * * /data/opt/sphinx/bin/indexer --config /data/opt/sphinx/etc/sphinx.conf dzbbs_merge --rotate && /data/opt/sphinx/bin/indexer --config /data/opt/sphinx/etc/sphinx.conf --merge dzbbs dzbbs_merge --rotate # Incremental Index threads data* 0-3 * * * /data/opt/sphinx/bin/indexer --config /data/opt/sphinx/etc/sphinx.conf threads_delta --rotate* 6-23 * * * /data/opt/sphinx/bin/indexer --config /data/opt/sphinx/etc/sphinx.conf threads_delta --rotate0 4 * * * /data/opt/sphinx/bin/indexer --config /data/opt/sphinx/etc/sphinx.conf threads_merge --rotate && /data/opt/sphinx/bin/indexer --config /data/opt/sphinx/etc/sphinx.conf --merge threads threads_merge --rotate
注:
1、xx_delta每分鐘進(jìn)行增量數(shù)據(jù)更新是為了能夠及時(shí)查找到新的帖子和回復(fù),但并不會更新sph_counter表的記錄。此處不進(jìn)行記錄更新和merge是因?yàn)楫?dāng)數(shù)據(jù)量大以及論壇發(fā)帖頻繁的時(shí)候一分鐘之內(nèi)有可能合并不完,間隔時(shí)間長的話又不能及時(shí)查找到。
2、dzbbs_merge、 threads_merge 是為了將第一次執(zhí)行的主數(shù)據(jù)與之后的新的數(shù)據(jù)進(jìn)行合并,如果長時(shí)間不合并,那么每次執(zhí)行xx_delta的時(shí)間就會很長,一分鐘之內(nèi)執(zhí)行不完。
原帖是用來解決dz搜索問題的:
http://code.google.com/p/dzwithsphinx/
分布式搜索:
index dist
{
type = distributed
local = chunk1
agent = localhost:3312:chunk2
agent = localhost:3312:chunk3
agent = localhost:3312:chunk4
}