Sphinx站內搜索

1、Sphinx流程mysql

Mysql數據  -》 sphinx -》 索引數據sql


2、sphinx概述vim

3、Sphinx使用地方後端

一、網站中的搜索(站內搜索)服務器

二、系統後臺中的搜索ide


4、爲何要使用Sphinx
工具

當數據超過100W時,咱們須要使用第三方工具,Sphinx。性能

一、作搜索時當數據量大單純的Mysql搜索比較慢(若是進行了分表會更慢)
網站

    如200W數據,查詢記錄中帶某個字的數據:ui

   mysql> select * from article where title like '%孩子';

  模糊查詢耗費時間:9.28s

二、搜索時中文分詞

  如搜:劉德華,會將劉德華,劉華,馬德華相關的搜索匹配出來。

三、Sphinx快

   高速的創建索引(在當代CPU中,峯值性能高達10M/s)

   高性能的搜索(在2-4G的文本數據上,平均每次檢索時間小於0.1s)

   可處理海量數據 


5、獲取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 後端的進程


6、Sphinx配置

一、嘗試開啓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#



7、Indexer

  經過Indexer工具產生索引數據

8、searched

該工具默認安裝在:root@112: cd /usr/bin 目錄下

相關文章
相關標籤/搜索