mysql站内搜索_Sphinx站内搜索

一、Sphinx流程

Mysql数据  -》 sphinx -》 索引数据

二、sphinx概述

f9b300cd3b839d9980608d25870239e1.png

三、Sphinx使用地方

1、网站中的搜索(站内搜索)

2、系统后台中的搜索

2e7a5c57fd131216fb224669ea01760d.png

四、为什么要使用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

Deb packages:

Sphinx requires a few libraries to be installed on Debian/Ubuntu. Use apt-get to download and install these dependencies:

$ sudo apt-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

ea8a818188d2980e3debe27f463236f5.png

使用命令搜索:

root@iZ94j7:/# whereis sphinxsearch

sphinxsearch: /etc/sphinxsearch                  // 用来存放sphinx当中的一些配置文件

安装好后,还会有2个工具,存放在/usr/bin/下边

root@iZ94j7:/# usr/bin$ indexer  创建索引

root@iZ94j7:/#usr/bin$ searched 后端的进程

六、Sphinx配置

9aa0858b7b01d0ca9950915a5d320704.png

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#

2e0440516fb25b2fc5b7087df04fca8a.png

七、Indexer

通过Indexer工具产生索引数据

八、searched

该工具默认安装在:root@112: cd /usr/bin 目录下

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值