环境:
操作系统:ubuntu
coreseek:3.2
目的:对phpcms添加全文索引功能。
官方文档:http://www.coreseek.cn/docs/coreseek_3.2-sphinx_0.9.9.html
------------------------------
进入coreseek的目录下进行安装:
/usr/local/src/coreseek-3.2.14/csft-3.2.14
./configure --prefix=/var/lib/coreseek --with-mysql=/var/lib/mysql --with-mmseg=/var/lib/mmseg --with-mmseg-includes=/var/lib/mmseg/include/mmseg/ --with-mmseg-libs=/var/lib/mmseg/lib/
make && make install
这里的安装跟上面sphinx一样的,就是加入了LibMMseg分词,安装完创建测试数据,
创建搜索配置文件csft.conf,过程跟安装测试sphinx一样,但是创建索引时报了一个这样的错误:
FATAL: index 'test1': 'synonyms': failed to open '/data/exceptions.txt',
进入配置文件csft.conf,把/data/exceptions.txt注释掉即可,创建完索引,运行测试OK。
要进行中文分词搜索请在配置文件中加入
修改charset_type= zh_cn.utf-8
charset_dictpath = /var/lib/mmseg/etc/
在示例配置文件中,将试图对MySQL数据库test
中的 documents
表建立索引;因此在这里还提供了 example.sql
用于给测试表增加少量数据用于测试:
$ mysql -u test < /usr/local/coreseek/etc/example.sql
注意修改数据库的编码为utf-8.并且插入中文记录来测试。关于csft.conf配置文件的解释 可参考:http://wenku.baidu.com/view/1774e0efe009581b6bd9eb3c.html
另外说明:我用SerureCRT 来远程连接ubuntu操作的,在显示问方面会有乱码问题,用vm的ssh连接就没问题。
测试:
$ /opt/coreseek/bin/search 我爱鸡冠花
index 'test1stemmed': query '我爱鸡冠花 ': returned 0 matches of 0 total in 0.000 sec
words:
1. '我': 2 documents, 2 hits
2. '爱': 0 documents, 0 hits
3. '鸡冠花': 0 documents, 0 hits
分词成功。