sphinx使用心得
来源:互联网 发布:中国在中东知乎 编辑:程序博客网 时间:2024/06/04 20:04
近期领导觉得网站的搜索太慢了。让我们优化一下。经过研究。感觉之前使用的like查询效率太低。所以导致查询速度慢。从网上找到了sphinx。据说这个软件是做搜索用的。可以大大提高效率。由于之前从来没有接触过。所以只能对着文档进行研究。由于我们的网站是纯英文的。所以只需要sphinx即可。针对中文做全文索引的软件叫coreseek。最初我认为sphinx就是一个数据库。和mysql类似。只是比mysql效率高。经过研究,发现并不是那么回事。
sphinx是对数据库里的表做索引。需要查询的数据提交到sphinx进行查询。返回在mysql数据库里的id,让后拿id去mysql数据库里去查询。
1、先安装sphinxclient #cd /usr/local/src #wget http://sphinxsearch.com/files/sphinx-0.9.9.tar.gz #tar xzvf sphinx-0.9.9.tar.gz #cd sphinx-0.9.9/api/libsphinxclient #vim sphinxclient.c 找到 void sock_close ( int sock ); 改为 static void sock_close ( int sock ); #./configure --prefix=/usr/local/sphinxclient #make #make install 2、安装sphinx扩展 #wget http://pecl.php.net/get/sphinx-1.0.4.tgz #tar xvzf sphinx-1.0.4.tgz #cd sphinx-1.0.4 #/usr/local/php/bin/phpize #./configure --with-php-config=/usr/local/php/bin/php-config --with-sphinx=/usr/local/sphinxclient #make #make install 修改php.ini extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/" [sphinx] extension=sphinx.so
#vim sphinx.php <?php $s = new SphinxClient; setServer("localhost", 9312); $s->setMatchMode(SPH_MATCH_ANY); $s->setMaxQueryTime(3); $result = $s->query("demo"); var_dump($result); ?> #/usr/local/php/bin/php sphinx.php 运行结果 array(9) { ["error"]=> string(0) "" ["warning"]=> string(0) "" ["status"]=> int(0) ["fields"]=> array(5) { [0]=> string(6) "cat_id" [1]=> string(13) "provider_name" [2]=> string(12) "goods_number" [3]=> string(18) "promote_start_date" [4]=> string(8) "keywords" } ["attrs"]=> array(8) { ["goods_sn"]=> string(1) "3" ["goods_name"]=> string(1) "3" ["brand_id"]=> string(1) "1" ["goods_weight"]=> string(1) "5" ["market_price"]=> string(1) "5" ["shop_price"]=> string(1) "5" ["promote_price"]=> string(1) "5" ["gid"]=> string(10) "1073741825" } ["total"]=> int(0) ["total_found"]=> int(0) ["time"]=> float(0) ["words"]=> array(1) { ["demo"]=> array(2) { ["docs"]=> int(0) ["hits"]=> int(0) } }}
- sphinx使用心得
- sphinx 使用
- Sphinx使用
- 使用sphinx写文档
- Coreseek SPHINX使用
- sphinx的使用
- sphinx 安装使用
- sphinx使用初级
- sphinx使用篇
- sphinx使用笔记
- Ubuntu下使用Sphinx
- sphinx使用步骤
- sphinx的安装使用
- sphinx使用整理文档
- 使用sphinx创建搜索引擎
- sphinx安装,配置,使用
- sphinx使用学习笔记
- Sphinx 安装到使用
- poj3254 Corn Fields
- HTML 布局常见问题
- 敏捷开发_WorkBalance
- 逻辑运算符&&、||、!使用分析
- Vim+cscope+ctags+tags阅读源代码
- sphinx使用心得
- 【二分+广搜】poj 2485 Highways
- 位运算符分析
- Java中的多态的详细讲解
- aix 压缩软件及工具库 下载地址
- 巧用OpenCV计算图片序列(矩阵)的直方图
- ++、--操作使用分析
- Effective c++ 笔记—视c++ 为一个语言联邦
- 编程之美 2.18 数组分割