美文网首页
Coreseek安装与测试

Coreseek安装与测试

作者: 杍劼 | 来源:发表于2017-01-04 17:10 被阅读202次

    1.Coreseek介绍:

    Sphinx默认不支持中文索引及检索,基于Sphinx开发了Coreseek全文检索服务器,Coreseek应该是现在用的最多的Sphinx中文全文检索,它提供了为Sphinx设计的中文分词包LibMMSeg包含mmseg中文分词。

    2.coreseek安装:

    (1).下载中文分词包:http://www.coreseek.cn 到官网下载Coreseek相应的版本

    (2).解压安装:tar zxvf coreseek-3.2.14.tar.gz

    (3).先进入mmseg-3.2.14下,编译安装:

    ./configure --prefix=/opt/mmseg

    编译过程中报了一个错误:config.status: error: cannot find input file: src/Makefile.in,运行下列指令再次编译就能通过了:automake

    编译安装:make && make install

    (4).进入csft-3.2.14目录下,安装coreseek:

    ./configure --prefix=/opt/coreseek --with-mysql --with-mmseg=/opt/mmseg --with-mmseg-includes=/opt/mmseg/include/mmseg/ --with-mmseg-libs=/opt/mmseg/lib/

    make && make install

    3.修改coreseek配置文件:

    cd etc

    cp sphinx.conf.dist csft.conf

    修改csft.conf:

    //主数据源

    source main {

    //修改以下几行

    sql_host = localhost

    sql_user = root

    sql_pass =

    sql_db = test

    sql_port = 3306

    sql_sock = /var/lib/mysql/mysql.sock

    sql_query_pre = SET NAMES utf8

    sql_query_pre = SET SESSION query_cache_type=OFF

    sql_query = SELECT id,title,content FROM post

    sql_query_info = SELECT * FROM post WHERE id=$id

    //注释掉以下几行

    # sql_attr_uint = group_id

    # sql_attr_timestamp = date_added

    # sql_ranged_throttle = 0

    }

    //主数据索引

    index main{

    //修改以下几行

    source = main

    path = /opt/coreseek/var/data/main

    charset_type = zh_cn.utf-8    //编码格式

    charset_dictpath = /opt/mmseg/etc/    #你安装mmseg的目录

    //注释掉以下几行

    #stopwords = G:\data\stopwords.txt

    #wordforms = G:\data\wordforms.txt

    #exceptions = /data/exceptions.txt

    #charset_type = sbcs

    }

    //索引器

    indexer {

    mem_limit = 128M

    }

    //服务进程

    searchd {

    //不需要修改

    }

    4.coreseek测试:

    (1).修改/etc/my.cnf:

    [mysqld]

    character-set-server=utf8

    [client]

    default-character-set=utf8

    (2).查看字符编码:

    (3).搜索测试:

    cd bin

    ./indexer --all

    ./search 杍劼

    5.php加载sphinx模块:

    (1).sphinx集成到php程序中,有两种方式:

    sphinx php模块

    sphinxapi类:在/usr/local/soft/coreseek-3.2.14/csft-3.2.14/api中,找到sphinxapi.php,通过include这个文件可以使用sphinx函数

    (2).通过php连接sphinx来进行搜索,需要以下条件:

    数据表有相应数据

    建立sphinx配置文件

    生成索引

    启动sphinxd服务进程,并开启端口9312

    用php客户程序去连接sphinx服务

    (3).启动sphinx服务:

    启动服务进程命令:searchd

    -c:指定配置文件

    --stop:停止服务

    --pidfile:显式指定一个PID文件

    -p:指定端口

    (4).安装php的sphinx模块:

    ①.下载解压sphinx模块:

    wget http://pecl.php.net/get/sphinx

    tar zxvf sphinx

    ②.编译安装sphinx模块:

    cd sphinx-1.3.3/

    /opt/php5.5/bin/phpize

    ./configure --with-php-config=/opt/php5.5/bin/php-config

    提示出错:configure: error: Cannot find libsphinxclient headers

    ③.编译安装libsphinxclient:

    cd ../coreseek-3.2.14/csft-3.2.14/api/libsphinxclient/

    ./configure

    make && make install

    ④.重复第②步,成功后再make && make install

    ⑤.修改php.ini文件:

    [sphinx]

    extension=sphinx.so

    ⑥.重启php-fpm进程:service php5.5-fpm restart

    相关文章

      网友评论

          本文标题:Coreseek安装与测试

          本文链接:https://www.haomeiwen.com/subject/putavttx.html