| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
MohammadLan
8年前发布

Sphinx站内搜索

来自: http://my.oschina.net/corwien/blog/626217


一、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:

  1. 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

  2. Now you can install Sphinx:

    $ sudo apt-get install sphinxsearch

  3. 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#


 

 本文由用户 MohammadLan 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1456796577609.html
Sphinx 搜索引擎