Sphinx站内搜索
2016-03-01 00:00
726 查看
摘要: Sphinx检索
一、Sphinx流程
Mysql数据 -》 sphinx -》 索引数据
二、sphinx概述
三、Sphinx使用地方
1、网站中的搜索(站内搜索)
2、系统后台中的搜索
四、为什么要使用Sphinx
当数据超过100W时,我们需要使用第三方工具,Sphinx。
1、做搜索时当数据量大单纯的Mysql搜索比较慢(如果进行了分表会更慢)
如200W数据,查询记录中带某个字的数据:
mysql> select * from article where title like '%孩子';
模糊查询耗费时间:9.28s
2、搜索时中文分词
如搜:刘德华,会将刘德华,刘华,马德华相关的搜索匹配出来。
3、Sphinx快
高速的建立索引(在当代CPU中,峰值性能高达10M/s)
高性能的搜索(在2-4G的文本数据上,平均每次检索时间小于0.1s)
可处理海量数据
五、获取Sphinx
官方地址:http://sphinxsearch.com/ ,Sphinx必须安装在服务器中
Deb packages:
Sphinx requires a few libraries to be installed on Debian/Ubuntu. Use apt-get to download and install these dependencies:
Now you can install Sphinx:
start sphinxsearch
root@iZ9:/# sudo service sphinxsearch start
To enable sphinxsearch, edit /etc/default/sphinxsearch and set START=yes
编辑sphinx配置:
root@iZ94j7ehy5oZ:/# vim /etc/default/sphinxsearch
使用命令搜索:
root@iZ94j7:/# whereis sphinxsearch
sphinxsearch: /etc/sphinxsearch // 用来存放sphinx当中的一些配置文件
安装好后,还会有2个工具,存放在/usr/bin/下边
root@iZ94j7:/# usr/bin$ indexer 创建索引
root@iZ94j7:/# usr/bin$ searched 后端的进程
六、Sphinx配置
1、尝试开启sphinx服务
root@iZ94j7:/usr/share# sudo service sphinxsearch start
Starting sphinxsearch:
// 提示需要先进行配置
Please create an /etc/sphinxsearch/sphinx.conf configuration file.
A template is provided as /etc/sphinxsearch/sphinx.conf.sample.
root@iZ94j7:/usr/share#
七、Indexer
通过Indexer工具产生索引数据
八、searched
该工具默认安装在:root@112: cd /usr/bin 目录下
一、Sphinx流程
Mysql数据 -》 sphinx -》 索引数据
二、sphinx概述
三、Sphinx使用地方
1、网站中的搜索(站内搜索)
2、系统后台中的搜索
四、为什么要使用Sphinx
当数据超过100W时,我们需要使用第三方工具,Sphinx。
1、做搜索时当数据量大单纯的Mysql搜索比较慢(如果进行了分表会更慢)
如200W数据,查询记录中带某个字的数据:
mysql> select * from article where title like '%孩子';
模糊查询耗费时间:9.28s
2、搜索时中文分词
如搜:刘德华,会将刘德华,刘华,马德华相关的搜索匹配出来。
3、Sphinx快
高速的建立索引(在当代CPU中,峰值性能高达10M/s)
高性能的搜索(在2-4G的文本数据上,平均每次检索时间小于0.1s)
可处理海量数据
五、获取Sphinx
官方地址:http://sphinxsearch.com/ ,Sphinx必须安装在服务器中
Deb packages:
Sphinx requires a few libraries to be installed on Debian/Ubuntu. Use apt-get to download and install these dependencies:
$ sudoapt-get install mysql-client unixodbc libpq5
Now you can install Sphinx:
$ sudoapt-get install sphinxsearch
start sphinxsearch
root@iZ9:/# sudo service sphinxsearch start
To enable sphinxsearch, edit /etc/default/sphinxsearch and set START=yes
编辑sphinx配置:
root@iZ94j7ehy5oZ:/# vim /etc/default/sphinxsearch
使用命令搜索:
root@iZ94j7:/# whereis sphinxsearch
sphinxsearch: /etc/sphinxsearch // 用来存放sphinx当中的一些配置文件
安装好后,还会有2个工具,存放在/usr/bin/下边
root@iZ94j7:/# usr/bin$ indexer 创建索引
root@iZ94j7:/# usr/bin$ searched 后端的进程
六、Sphinx配置
1、尝试开启sphinx服务
root@iZ94j7:/usr/share# sudo service sphinxsearch start
Starting sphinxsearch:
// 提示需要先进行配置
Please create an /etc/sphinxsearch/sphinx.conf configuration file.
A template is provided as /etc/sphinxsearch/sphinx.conf.sample.
root@iZ94j7:/usr/share#
七、Indexer
通过Indexer工具产生索引数据
八、searched
该工具默认安装在:root@112: cd /usr/bin 目录下
相关文章推荐
- 一个关于if else容易迷惑的问题
- PHP5.2.*防止Hash冲突拒绝服务攻击的Patch
- 深入理解PHP之匿名函数
- JSP/PHP基于Ajax的分页功能实现
- 关于PHP通过PDO用中文条件查询MySQL的问题。
- 什么是设计模式
- PHP数据库长连接mysql_pconnect的细节
- Php Installing An Expansion
- PHP+Apache在Windows 9x下的安装和配置
- IIS 6 的 PHP 最佳配置方法
- 安装Apache和PHP的一些补充
- Linux Apache+MySQL+PHP
- 建立Apache+PHP+MySQL数据库驱动的动态网站
- PHP 5.3.0 安装分析心得
- apache 环境下 php 的配置注意事项
- ASP.NET、ASP、PHP、JSP之间有什么区别?
- PHP VBS JS 函数 对照表
- C语言实现的统计php代码行数功能源码(支持文件夹、多目录)
- php xml 入门学习资料