安装sphinx(三)

##确保可以正常显示,否则请检查当前环境的locale配置,以及当前环境或者客户端已设置好支持UTF-8中文字符显示

locale命令查看编码字符,如

LANG=zh_CN.UTF-8
LC_ALL=zh_CN.UTF-8


##安装coreseek开发的mmseg,为coreseek提供中文分词功能
$ cd mmseg-3.2.14
$ ./bootstrap
$ ./configure --prefix=/usr/local/mmseg3    ##词典和配置文件,将自动安装到/usr/local/mmseg3/etc
$ make && make install


mmseg安装完成


##中文分词测试,如果显示不正常,请检查当前环境下的locale和UTF-8中文字符显示设置
$  /usr/local/mmseg3/bin/mmseg -d /usr/local/mmseg3/etc src/t1.txt
    中文/x 分/x 词/x 测试/x 
    中国人/x 上海市/x 


##安装coreseek:
$ cd csft-3.2.14
##执行configure,进行编译配置:
$ sh buildconf.sh
$ ./configure --prefix=/usr/local/coreseek --without-python --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg3/lib/ --without-mysql
##coreseek4.x/sphinx1.x,请将--without-mysql更改为--with-mysql
$ make && make install




##配置测试,测试是否可以正确运行
$ /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx-min.conf.dist
##以下为正常测试时的提示信息:
    Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]
    Copyright (c) 2007-2010,
    Beijing Choice Software Technologies Inc (http://www.coreseek.com)
    using config file '/usr/local/coreseek/etc/sphinx-min.conf.dist'...
    total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
    total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg



##coreseek基础环境安装完成。
##注意:基础环境仅支持xml数据源;如需要mysql或者python数据源,请继续按照下面的步骤操作!!!
 
##二、数据源支持:支持MySQL数据源
##系统需要安装相关的基础依赖库,否则无法支持对应的功能

$ yum install mysql-devel libxml2-devel expat-devel


##重新编译安装coreseek,以支持mysql数据源和xml数据源
$ cd csft-3.2.14
$ make clean
$ ./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

##以上configure参数请正确拷贝,不要遗漏或者随意修改
$ make && make install


##三、coreseek中文全文检索测试
配置xml数据源

$ cd testpack
$  /usr/local/coreseek/bin/indexer -c etc/csft.conf

##以下为正常情况下的提示信息:
    Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]
    Copyright (c) 2007-2010,
    Beijing Choice Software Technologies Inc (http://www.coreseek.com)
    using config file 'etc/csft.conf'...
    total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
    total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg

$  /usr/local/coreseek/bin/indexer -c etc/csft.conf --all
    Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]
    Copyright (c) 2007-2010,
    Beijing Choice Software Technologies Inc (http://www.coreseek.com)
    using config file 'etc/csft.conf'...
    indexing index 'xml'...
    collected 3 docs, 0.0 MB
    sorted 0.0 Mhits, 100.0% done
    total 3 docs, 7585 bytes
    total 0.075 sec, 101043 bytes/sec, 39.96 docs/sec
    total 2 reads, 0.000 sec, 5.6 kb/call avg, 0.0 msec/call avg
    total 7 writes, 0.000 sec, 3.9 kb/call avg, 0.0 msec/call avg



$  /usr/local/coreseek/bin/indexer -c etc/csft.conf xml
    Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]
    Copyright (c) 2007-2010,
    Beijing Choice Software Technologies Inc (http://www.coreseek.com)
    using config file 'etc/csft.conf'...
    indexing index 'xml'...
    collected 3 docs, 0.0 MB
    sorted 0.0 Mhits, 100.0% done
    total 3 docs, 7585 bytes
    total 0.069 sec, 109614 bytes/sec, 43.35 docs/sec
    total 2 reads, 0.000 sec, 5.6 kb/call avg, 0.0 msec/call avg
    total 7 writes, 0.000 sec, 3.9 kb/call avg, 0.0 msec/call avg


$  /usr/local/coreseek/bin/search -c etc/csft.conf
    Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]
    Copyright (c) 2007-2010,
    Beijing Choice Software Technologies Inc (http://www.coreseek.com)
    using config file 'etc/csft.conf'...
    index 'xml': query '': returned 3 matches of 3 total in 0.093 sec

    displaying matches:
    1. document=1, weight=1, published=Thu Apr  1 22:20:07 2010, author_id=1
    2. document=2, weight=1, published=Thu Apr  1 23:25:48 2010, author_id=1
    3. document=3, weight=1, published=Thu Apr  1 12:01:00 2010, author_id=2

    words:


$  /usr/local/coreseek/bin/search -c etc/csft.conf -a Twittter和Opera都提供了搜索服务

   Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]
    Copyright (c) 2007-2010,
    Beijing Choice Software Technologies Inc (http://www.coreseek.com)
    using config file 'etc/csft.conf'...
    index 'xml': query 'Twittter和Opera都提供了搜索服务 ': returned 3 matches of 3 total in 0.038 sec

    displaying matches:
    1. document=3, weight=24, published=Thu Apr  1 12:01:00 2010, author_id=2
    2. document=1, weight=4, published=Thu Apr  1 22:20:07 2010, author_id=1
    3. document=2, weight=3, published=Thu Apr  1 23:25:48 2010, author_id=1

    words:
    1. 'twittter': 1 documents, 3 hits
    2. '和': 3 documents, 15 hits
    3. 'opera': 1 documents, 25 hits
    4. '都': 2 documents, 4 hits
    5. '提供': 0 documents, 0 hits
    6. '了': 3 documents, 18 hits
    7. '搜索': 2 documents, 5 hits
    8. '服务': 1 documents, 1 hits


$  /usr/local/coreseek/bin/searchd -c etc/csft.conf
    Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]
    Copyright (c) 2007-2010,
    Beijing Choice Software Technologies Inc (http://www.coreseek.com)

    using config file 'etc/csft.conf'...
    listening on all interfaces, port=9312

##mysql数据源测试

/usr/local/coreseek/bin/indexer -c etc/csft_mysql.conf
/usr/local/coreseek/bin/indexer -c etc/csft_mysql.conf --all
/usr/local/coreseek/bin/indexer -c etc/csft_mysql.conf mysql
/usr/local/coreseek/bin/search -c etc/csft_mysql.conf
/usr/local/coreseek/bin/search -c etc/csft_mysql.conf -a 百度与Google划洋而治

##通过以上步骤,coreseek已经安装测试完成。


##如要停止搜索服务,请使用/usr/local/coreseek/bin/searchd -c etc/csft.conf --stop
##如要已启动服务,要更新索引,请使用/usr/local/coreseek/bin/indexer -c etc/csft.conf --all --rotate


##自动化命令:
crontab -e  

*/1 * * * * /bin/sh /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/csft_mysql.conf delta --rotate  
30 1 * * *  /bin/sh /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/csft_mysql.conf --all --rotate  

每隔一分钟执行一遍增量索引,每天1:30执行整体索引


##然后,请参考csft-3.2.14下api目录中的相关文件,使用PHP来测试搜索服务;查看安装sphinx(四)使用PHP测试。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值