CentOS7下安装coreseek

yum install expat-devel*

cd /usr/local/src

wget http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.14.tar.gz

tar xzvf coreseek-3.2.14.tar.gz

cd coreseek-3.2.14

cd mmseg-3.2.14

./bootstrap

./configure --prefix=/usr/local/mmseg3

make && make install

cd ..

cd csft-3.2.14

wget -O - http://blog.atime.me/static/resource/sphinxexpr-gcc4.7.patch.gz | gzip -d - | patch -p0
或者
直接修改src/sphixexpr.cpp文件的1746, 1777和1823行,将三行中的ExprEval改为this->ExprEval
参考http://blog.atime.me/note/sphinx-coreseek-summary.html

sh buildconf.sh

./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

cd ..

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

mysql数据源的配置可参考testpack/etc/csft_mysql.conf文件

vi etc/csft_mysql.conf

#MySQL数据源配置,详情请查看:http://www.coreseek.cn/products-install/mysql/
#请先将var/test/documents.sql导入数据库,并配置好以下的MySQL用户密码数据库

#源定义
source mysql
{
    type                    = mysql

    sql_host                = localhost
    sql_user                = root
    sql_pass                = 123456
    sql_db                    = test
    sql_port                = 3306
    sql_query_pre            = SET NAMES utf8

    sql_query                = SELECT id, group_id, UNIX_TIMESTAMP(date_added) AS date_added, title, content FROM documents
                                                              #sql_query第一列id需为整数
                                                              #title、content作为字符串/文本字段,被全文索引
    sql_attr_uint            = group_id           #从SQL读取到的值必须为整数
    sql_attr_timestamp        = date_added #从SQL读取到的值必须为整数,作为时间属性

    sql_query_info_pre      = SET NAMES utf8                                        #命令行查询时,设置正确的字符集
    sql_query_info            = SELECT * FROM documents WHERE id=$id #命令行查询时,从数据库读取原始数据信息
}

#index定义
index mysql
{
    source            = mysql             #对应的source名称
    path            = /var/lib/mysql #请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...
    docinfo            = extern
    mlock            = 0
    morphology        = none
    min_word_len        = 1
    html_strip                = 0

    #中文分词配置,详情请查看:http://www.coreseek.cn/products-install/coreseek_mmseg/
    charset_dictpath = /usr/local/mmseg3/etc/ #BSD、Linux环境下设置,/符号结尾
    #charset_dictpath = etc/                             #Windows环境下设置,/符号结尾,最好给出绝对路径,例如:C:/usr/local/coreseek/etc/...
    charset_type        = zh_cn.utf-8
}

#全局index定义
indexer
{
    mem_limit            = 128M
}

#searchd服务定义
searchd
{
    listen                  =   9312
    read_timeout        = 5
    max_children        = 30
    max_matches            = 1000
    seamless_rotate        = 0
    preopen_indexes        = 0
    unlink_old            = 1
    pid_file = /var/log/searchd_mysql.pid  #请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...
    log = /var/log/searchd_mysql.log        #请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...
    query_log = /var/log/query_mysql.log #请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...
}

正常开启搜索服务

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

vi /etc/profile

添加 PATH=$PATH:/usr/local/php/bin

再source /etc/profile

然后执行

php api/test_coreseek.php

即可看到搜索结果

发表评论