sphinx 的安装与应用

1、php的windoes sphinx扩展安装
      下载dll文件,http://windows.php.net/downloads/pecl/releases/sphinx/1.3.3/
      下载的文件放在php的ext目录下,在php.ini加上extension=php_sphinx.dll

  php的linux  sphinx扩展安装
      下载地址:http://pecl.php.net/package/sphinx
      wgethttp://pecl.php.net/get/sphinx-1.3.0.tgz 
      tarzxf sphinx-1.3.0.tgz 
      cdsphinx-1.3.0 
      /usr/local/php/bin/phpize 
      ./configure --with-php-config=/usr/local/php/bin/php-config--with-sphinx=/usr/local/sphinx/ 
      make&& make install

2、 sphinx服务安装
CoreSeek官方网站:
http://www.coreseek.cn/
http://www.coreseek.cn/products/="/products-install/step_by_step/
http://www.coreseek.cn/products-install/mysql/

具体操作:
一、安装编译工具
yum install make gcc g++ gcc-c++ libtool autoconf automakeimake mysql-devel libxml2-devel expat-devel
二 、安装CoreSeek
1、下载CoreSeek
下载地址:http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.14.tar.gz
2、安装mmseg
tar zxvf coreseek-3.2.14.tar.gz #解压
cd coreseek-3.2.14/ mmseg-3.2.14
./bootstrap #输出的warning信息可以忽略
./configure --prefix=/usr/local/mmseg3 #配置
make && make install # #编译安装
3、安装CoreSeek
cd coreseek-3.2.14/csft-3.2.14
sh buildconf.sh #输出的warning信息可以忽略
./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# #编译 安装
 
 
3、建立索引文件
/usr/local/coreseek/bin/indexer-c  /usr/local/coreseek/etc/csft_mysql.conf --all# 生成全部索引文件的命令
/usr/local/coreseek/bin/indexer-c  /usr/local/coreseek/etc/csft_mysql.conf --all  --rotate 
#--rotate:该参数可以使我们在不需要停止searchd的情况下,直接加载索引

/usr/local/coreseek/bin/indexer-c  /usr/local/coreseek/etc/csft_mysql.conf  --rotateindex_search_main
#生成主索引
/usr/local/coreseek/bin/indexer-c  /usr/local/coreseek/etc/csft_mysql.conf  --rotateindex_search_main_delta
#生成增量索引
/usr/local/coreseek/bin/indexer -c/ usr/local/coreseek/etc/csft_mysql.conf    --mergeindex_search_main index_search_main_delta --rotate
#增量索引和主索引的合并

/usr/local/coreseek/bin/searchd-c  / usr/local/coreseek/etc/csft_mysql.conf    开启
/usr/local/coreseek/bin/searchd-c  / usr/local/coreseek/etc/csft_mysql.conf  --stop为关闭

4、API调用

$index = 'test1';
$key = '北';

$sc = new SphinxClient();
$sc->SetServer('192.168.33.10',9312);
#$sc->SetMatchMode(SPH_MATCH_ALL);
$sc->SetMatchMode(SPH_MATCH_EXTENDED);
$sc->SetArrayResult(TRUE);
$res = $sc->Query($ key,$index);
$err = $sc->GetLastError();
print_r($res);
print_r($err);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值