Sphinx中文分词在discuz 中的应用(4)
}
#pre_forum_post_minute
source pre_forum_post_minute : pre_forum_post
{
sql_query_pre = SET NAMES UTF8
sql_query_pre = SET SESSION query_cache_type=OFF
sql_query_range = SELECT maxid-1,(SELECT MAX(pid) FROM pre_forum_post) FROM pre_common_sphinxcounter WHERE indexid=2
}
#pre_forum_post_minute
index pre_forum_post_minute : pre_forum_post
{
source = pre_forum_post
path = /data0/dzbbs/indexdata/pre_forum_post #windows下最好用全路径
}
#全局indexer定义
indexer
{
mem_limit = 2047M
write_buffer = 64M
}
#searchd服务定义
searchd
{
listen = 3312
read_timeout = 5
max_children = 30
max_matches = 500
listen_backlog = 20
seamless_rotate = 0
preopen_indexes = 0
max_filter_values = 16384
max_filters = 1024
mva_updates_pool = 16M
max_packet_size = 32M
read_buffer = 1M
unlink_old = 1
pid_file = /usr/local/sfc22/var/log/searchd_discuzx.pid #windows下最好用全路径
log = /usr/local/sfc22/var/log/searchd_discuzx.log #windows下最好用全路径
query_log = /usr/local/sfc22/var/log/query_discuzx.log #windows下最好用全路径
}
4 测试sfc 中文分词效果。
/usr/local/sfc22/bin/search -c /usr/local/sfc22/etc/sphinx.conf 分享精彩
words:
1. '分享': 194 documents, 266 hits
2. '精彩': 368 documents, 425 hits
3. '精彩视频': 2 documents, 2 hits
4. '精彩节目': 2 documents, 2 hits
5. '精彩绝伦': 2 documents, 2 hits
6. '精彩纷呈': 7 documents, 7 hits
7. '精彩瞬间': 5 documents, 5 hits
8. '精彩回顾': 2 documents, 3 hits
可以看出sfc 中文分词效果还是比较准确的。
5 启动sfc
/usr/local/sfc22/bin/searchd -c /usr/local/sfc22/etc/sphinx.conf
6 编写主索引和增量索引脚本
1)编写主题表主索引和增量索引以及帖子表增量索引,每20分钟运行一次。
vim /usr/local/bin/bbssearch.sh
#!/bin/bash #desc: this scripts for sphinx for chinese index #date:2014.12.23 #testd in CentOS 6.5 x86_64 #saved in /usr/local/bin/bbssearch.sh #written by coralzd@gmail.com coralzd.blog.51cto.com blog.zjyxh.com export PATH=/usr/local/sfc22/bin/:/sbin/:$PATH Y=$(date +%Y) m=$(date +%m) d=$(date +%d) # create thread merge index echo "-- thread main index start `date +${Y}-${m}-${d}.%H:%M:%S` --" >> /var/log/sphinx.log indexer pre_forum_thread_minute --rotate echo "-- thread merge index end `date +${Y}-${m}-${d}.%H:%M:%S` --" >> /var/log/sphinx.log # create post merge index echo "-- post main index start `date +${Y}-$m-$d.%H:%M:%S` --" >> /var/log/sphinx.log indexer pre_forum_post_minute --rotate echo "-- post merge index end `date +${Y}-$m-$d.%H:%M:%S` --" >> /var/log/sphinx.log # main index + merge index thread echo "-- thread main merge + index start `date +${Y}-${m}-${d}.%H:%M:%S` --" >> /var/log/sphinx.log indexer --merge pre_forum_thread pre_forum_thread_minute --merge-dst-range deleted 0 0 --rotate echo "-- thread main merge + index end `date +${Y}-${m}-${d}.%H:%M:%S` --" >> /var/log/sphinx.log
- 发表评论
-
- 最新评论 更多>>