Centos7安装coreseek中文检索引擎

一、介绍:

Coreseek 是一款中文全文检索/搜索软件,以GPLv2许可协议开源发布,基于Sphinx研发并独立发布,专攻中文搜索和信息处理领域,适用于行业/垂直搜索、论坛/站内搜索、数据库搜索、文档/文献检索、信息检索、数据挖掘等应用场景,用户可以免费下载使用。

coreseek版本信息:
Coreseek 3.2 稳定版
Coreseek 4.1 测式版
Coreseek 5 最新版

在这里我们使用的是 coreseek 3.2 稳定版进行演示

二、安装:

1、先安装环境:

yum install make gcc gcc++ gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel expat-devel

注: 检测以上软件是否安装,如果没有请确保安装;否则无法正常安装Coreseek-3.2.14

2、开始安装:

cd /usr/local/src     #把安装包放到此处

wget https://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.14.tar.gz        #下载CoreSeek,这里注意一下,这个路径现在暂时已经用不了(至少我写这篇博客的时候用不了),但是毕竟这是官网,还是要放一下的。我的网盘中有该软件 https://url.cn/2I77CON ,大家可以先下载到本地,然后再用 Filezilla 等软件上传到服务器即可。

tar -zxvf coreseek-3.2.14.tar.gz

cd coreseek-3.2.14  #解压出来的文件夹

##############安装 mmseg #################

cd mmseg-3.2.14

./bootstrap        #输出的warning信息可以忽略,如果出现error则需要解决,一般不会出现错误

./configure --prefix=/usr/local/mmseg3  #指定 mmseg 的安装目录

make && make install


#############安装 csft-3.2.14 ###############

cd /usr/local/src/csft-3.2.14

wget -O - https://blog.atime.me/static/resource/sphinxexpr-gcc4.7.patch.gz | gzip -d - | patch -p0

#或者

#直接修改src/sphixexpr.cpp文件的1746, 1777和1823行,将三行中的ExprEval改为this->ExprEval

#再或者

#这里我们要修改 src/sphinxexpr.cpp 文件,将该文件中的 1013、1047、1080 行的 ExprEval 改为 this->ExprEval(这里的行数跟网上的教程说的行数不一样,可能是版本的问题吧,但是如果你用的是我提供的版本,该行数是正确的),懂点 C++ 的同学也可以自己看看 ExprEval 错在哪里。

#改完上面所说的问题后:
sh buildconf.sh

#如果sh buildconf.sh最后没有生成configure脚本,且提示automake: warnings are treated as errors,可以将configure.ac中的这行

AM_INIT_AUTOMAKE([-Wall -Werror foreign])

改成

AM_INIT_AUTOMAKE([-Wall foreign])

#即删掉-Werror,然后重新运行sh buildconf.sh。

#如果configure的时候提示没有安装MySQL的头文件,安装libmysql++-dev包即可。

#如果你的gcc版本在4.7以上,编译的时候可能会因为sphinx的一个bug报错

sphinxexpr.cpp:1746:43: error: ‘ExprEval’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]

#解决方法参考bug报告里的一个patch,在csft-4.1目录下执行

wget -O - https://www.mawenbao.com/static/resource/sphinxexpr-gcc4.7.patch.gz | gzip -d - | patch -p0

#或者你也可以直接修改src/sphixexpr.cpp文件的1746, 1777和1823行,将三行中的ExprEval改为this->ExprEval。

./configure --prefix=/usr/local/coreseek  --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg3/lib/ --with-mysql

make && make install

在安装的过程中,只要不提示错误 error,那么其他的如 warning 信息都是可以忽略的。

至此我们已经成功的将中文检索引擎安装到我们服务器上来了。

三、测试:

cd testpack

cat var/test/test.xml   #此时应该正确显示中文

/usr/local/mmseg3/bin/mmseg -d /usr/local/mmseg3/etc var/test/test.xml  #整篇文章进行分词

/usr/local/coreseek/bin/indexer -c etc/csft.conf --all  #创建索引

/usr/local/coreseek/bin/search -c etc/csft.conf 网络搜索    #搜索关键字 网络搜索

/usr/local/coreseek/bin/searchd -c etc/csft.conf    #正常开启搜索服务

/usr/local/coreseek/bin/searchd -c etc/csft.conf --stop #如要停止搜索服务

/usr/local/coreseek/bin/indexer -c etc/csft.conf --all --rotate #如要已启动服务,要更新索引

四、其它常见问题

make && make install时出现问题

make[2]: *** [indexer] Error 1
make[2]: Leaving directory `/www/tmp/csft-3.1/src’
make[1]: *** [all] Error 2
make[1]: Leaving directory `/www/tmp/csft-3.1/src’
make: *** [all-recursive] Error 1

官网解决办法:

In the meantime I’ve change the configuration file and set
#define USE_LIBICONV 0 in line 8179.
修改 configure 文件把 #define USE_LIBICONV 0 最后的数值由1改为0
重新编译。
我使用的参数如下:

./configure –prefix=/usr/local/coreseek –with-mysql=/opt/lampp –with-mysql-includes=/opt/lampp/include/mysql/ –with-mysql-libs=/opt/lampp/lib/mysql/ –with-mmseg-includes=/usr/local/mmseg/include/mmseg –with-mmseg-libs=/usr/local/mmseg/lib/

编译错误一
make[2]: *** [indexer] Error 1
make[2]: Leaving directory `/www/tmp/csft-3.1/src’
make[1]: *** [all] Error 2
make[1]: Leaving directory `/www/tmp/csft-3.1/src’
make: *** [all-recursive] Error 1

解决办法

vi ./src/sphinx.cpp

注释以下代码
#case TOKENIZER_ZHCN_GBK:
#pTokenizer = sphCreateGBKChineseTokenizer
#(tSettings.m_sDictPath.cstr(), tSettings.m_nBest); break;

然后重新编译

make clean
make
make install

或者:

vi src/Makefile
LIBS = -lm -lexpat -L/usr/local/lib
修改为
LIBS = -lm -lexpat -liconv -L/usr/local/lib

错误二,索引出错
[root@localhost csft-3.1]# /usr/local/coreseek/bin/indexer –config /usr/local/coreseek/etc/sphinx.conf –all
/usr/local/coreseek/bin/indexer: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory

解决办法

ln -s /opt/lampp/lib/mysql/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16

错误三,索引不生成

解决办法,原来是手误,把/usr/local/coreseek/bin/indexer –config /usr/local/coreseek/etc/sphinx.conf –all
写成
/usr/local/coreseek/bin/indexer –config /usr/local/coreseek/etc/sphinx.conf -all

错误四,服务启动报错
[root@localhost coreseek]# ./bin/searchd –config /usr/local/coreseek/etc/sphinx.conf
Coreseek Full Text Server 3.1
Copyright (c) 2006-2008 coreseek.com
using config file ‘/usr/local/coreseek/etc/sphinx.conf’…
listening on all interfaces, port=3312
iniparser: cannot open /usr/local/coreseek/data/dict/mmseg.ini

解决办法

vi /usr/local/coreseek/data/dict/mmseg.ini

输入以下
[mmseg]
merge_number_and_ascii=1;
number_and_ascii_joint=-;
compress_space=0;
seperate_number_ascii=1;

3 thoughts on “Centos7安装coreseek中文检索引擎”

Leave a Comment