centos7下安装coreseek4.1
coreseek官方网站已经关门了,网上找了一个下载源
下载:https://gitee.com/sdagfsdh/coreseek?_from=gitee_search
先安装环境:
yum install make gcc gcc++ gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel expat-devel
注: 检测以上软件是否安装,如果没有请确保安装;否则无法正常安装Coreseek
开始安装:
#解压出来的文件夹
tar -zxvf coreseek-4.1-beta.tar.gz
cd coreseek-4.1-beta
##############安装 mmseg #################
cd mmseg-3.2.14
./bootstrap #输出的warning信息可以忽略,如果出现error则需要解决,一般不会出现错误
#指定 mmseg 的安装目录
./configure --prefix=/usr/local/mmseg
make && make install
然后运行mmseg,就能输入安装成功的信息了:
/usr/local/mmseg/bin/mmseg
出现下列信息,就证明mmseg中文分词已经安装好了。
接下来,我们要把Sphinx和mmseg结合起来
#############安装 csft ###############
进入coreseek-4.1-beta
先编辑configure.ac,修改
AM_INIT_AUTOMAKE([-Wall -Werror foreign])为
AM_INIT_AUTOMAKE([-Wall foreign])
修改 src/sphinxexpr.cpp 文件,
#改完上面所说的问题后:
sh buildconf.sh
./configure --prefix=/usr/local/coreseek --with-mmseg-includes=/usr/local/mmseg/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg/lib/ --with-mysql=/usr/local/mysql
make && make install
出现错误
libsphinx.a(sphinx.o): In function `xmlUnknownEncoding(void*, char const*, XML_Encoding*)': /home/coreseek-4.1-beta/csft-4.1/src/sphinx.cpp:22292: undefined reference to `libiconv_open' /home/coreseek-4.1-beta/csft-4.1/src/sphinx.cpp:22310: undefined reference to `libiconv' /home/coreseek-4.1-beta/csft-4.1/src/sphinx.cpp:22316: undefined reference to `libiconv_close' collect2: error: ld returned 1 exit status make[2]: *** [indexer] Error 1 make[2]: Leaving directory `/home/coreseek-4.1-beta/csft-4.1/src' make[1]: *** [all] Error 2 make[1]: Leaving directory `/home/coreseek-4.1-beta/csft-4.1/src' make: *** [all-recursive] Error 1
编辑/src/MakeFile文件把
LIBS = -ldl -lm -lz -lexpat -L/usr/local/lib -lrt -lpthread
在安装的过程中,只要不提示错误 error,那么其他的如 warning 信息都是可以忽略的。
至此我们已经成功的将coreseek中文检索引擎安装到我们服务器上来了。
############ 配置文件 ##############
安装成功后在/usr/local
coreseek中得配置文件也是csft.conf,而不是sphinx.conf
cd /usr/local/coreseek/etc cp sphinx.conf.dist csft.conf
csft.conf配置
1 source test 2 { 3 type = mysql 4 sql_host = localhost 5 sql_user = root 6 sql_pass = password 7 sql_db = database 8 sql_port = 3306 # optional, default is 3306 9 sql_query_pre = set names utf8; 10 sql_query_range = select min(id),max(id) from tablename; 11 sql_range_step = 10000 12 sql_query = select id,title from tablename where id>=$start and id<=$end; 13 14 } 15 16 index test 17 { 18 source = test 19 path = /mnt/sphinx/test 20 charset_type = zh_cn.utf-8 21 charset_dictpath = /usr/local/mmseg/etc/ #安装mmseg的目录 22 }
生成索引
#启动
/usr/local/coreseek/bin/searchd
#生成索引
/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/csft.conf --all --rotate
测试分词效果
/usr/local/coreseek/bin/search [-a] -c /usr/local/coreseek/etc/csft.conf '電腦滑鼠推薦'
导入词库
/usr/local/mmseg/bin/mmseg -u /usr/local/mmseg/etc/unigram.txt
mv unigram.txt.uni uni.lib