coreseek sphinx中文索引安装文档

in linux with 0 comment

安装依赖包

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

下载源码包及安装

下载地址https://github.com/zwxhenu/coreseek

wget https://codeload.github.com/zwxhenu/coreseek/zip/refs/heads/master -O coreseek.zip
unzip coreseek.zip
cd coreseek-master/

1. 安装mmseg

\##安装mmseg
cd mmseg-3.2.14
./bootstrap #输出的warning信息可以忽略,如果出现error则需要解决
./configure --prefix=/usr/local/mmseg3
make && make install
cd ..

2. 安装coreseek

cd csft-3.2.14
sh buildconf.sh #输出的warning信息可以忽略,如果出现error则需要解决
./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 ##如果提示mysql问题,可以查看MySQL数据源安装说明
make && make install
cd ..
 
cd /usr/local/coreseek/etc
cp sphinx-min.conf.dist sphinx.conf   ##配置文件
vi sphinx.conf

内容示例如下(localhost,DB_USER,DB_PASSWORD,DB_NAME自行修改)
#
# Minimal Sphinx configuration sample (clean, simple, functional)
#
 
source content
{
        type                                    = mysql
 
        sql_host                                = localhost
        sql_user                                = DB_USER
        sql_pass                                = DB_PASSWORD
        sql_db                                  = DB_NAME
        sql_port                                = 3306  # optional, default is 3306
        sql_query_pre                           = SET NAMES utf8
 
        sql_query                               = \
                SELECT id, title, pub_time, group_id, content FROM contents where status = '1'
 
        sql_attr_uint                   = group_id
        sql_attr_timestamp              = pub_time
 
        sql_query_info                  = SELECT * FROM contents WHERE id=$id
}
index content
{
        source                                  = content
        path                                    = /usr/local/coreseek/var/data/content
        docinfo                                 = extern
        charset_dictpath                        = /usr/local/mmseg3/etc/
        charset_type                            = zh_cn.utf-8
        ngram_len                               = 0
}
indexer
{
        mem_limit                               = 32M
}
 
searchd
{
        port                                    = 9312
        log                                     = /usr/local/coreseek/var/log/searchd.log
        query_log                               = /usr/local/coreseek/var/log/query.log
        read_timeout                            = 5
        max_children                            = 30
        pid_file                                = /usr/local/coreseek/var/log/searchd.pid
        max_matches                             = 1000
        seamless_rotate                         = 1
        preopen_indexes                         = 1
        unlink_old                              = 1
}

启动服务

/usr/local/coreseek/bin/searchd -c /usr/local/coreseek/etc/sphinx.conf

然后在coreseek目录下,新建3个sh脚本,以便操作
停止服务stop.sh

#!/bin/bash
/usr/local/coreseek/bin/searchd -c /usr/local/coreseek/etc/sphinx.conf --stop

建立索引build.sh

#!/bin/bash
/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf --all --rotate

启动服务start.sh

#!/bin/bash
/usr/local/coreseek/bin/searchd -c /usr/local/coreseek/etc/sphinx.conf

常见错误解决办法

1.error:cannot find input file: src/http://Makefile.in

yum -y install libtool
aclocal
libtoolize --force
automake --add-missing
autoconf
autoheader
make clean
./configure --prefix=/usr/local/mmseg3
make
make install

2.没有规则可以创建“all-am”需要的目标“data/uni.lib

 删除Makefile.am中的data/uni.lib 
 automake
 ./configure --prefix=/usr/local/mmseg3 
 make 
 make install

3.安装coreseek检查环境出现问题

3.1在 csft-4.1/buildconf.sh 文件&& aclocal 后加入:

&& automake --add-missing \

3.2把csft-4.1/configure.ac 文件中的AM_INIT_AUTOMAKE([-Wall -Werror foreign])改为:

AM_INIT_AUTOMAKE([-Wall foreign])

3.3在csft-4.1/configure.ac 文件中的AC_PROG_RANLIB后面加上:

m4_ifdef([AM_PROG_AR], [AM_PROG_AR])

3.4在 csft-4.1/src/sphinxexpr.cpp 文件中, 替换所有:

T val = ExprEval ( this->m_pArg, tMatch ); 为T val = this->ExprEval ( this->m_pArg, tMatch ); 

4.编译报错

4.1 遇到MySQL include files... configure: error: missing include files.解决办法:

yum install mysql-community-embedded-devel.x86_64  mysql-community-devel.x86_64 mysql++-devel.x86_64

4.2 提示libiconv无法找到,需要修改vi src/Makefile 文件,找 LIBS = 开头的行:

将LIBS = -lm -lz -lexpat  -L/usr/local/lib –lpthread
修改成:LIBS = -lm -lz -lexpat -liconv -L/usr/local/lib -lpthread

至此安装配置完成!

参考文档:
https://link.zhihu.com/?target=https%3A//my.oschina.net/u/1184253/blog/1558099
https://link.zhihu.com/?target=http%3A//blog.csdn.net/xuyaqun/article/details/7262278

Responses