Sphinx 死文克斯 聯合Mysql實現中文全文索引

來源:互聯網
上載者:User

標籤:bsp   res   編碼   常用   支援   img   style   image   產生   

        PHP進階工程師之Sphinx中文全文索引

    在這裡和大家分享一下Mysql5.5以後支援的全文索引Sphinx安裝配置和運行概念。

    如有不善,多提意見(QQ:1595068971-郵箱:[email protected])

  Sphinx伺服器支援網路

  工作原理

檔案包檔案

  api:使用php操縱Sphinx 訪問這個檔案。

  bin:經常用到的命令(產生Sphinx索引檔案,操縱服務)。

  etc:設定檔(csft_mysql.conf,uni.lib“海量詞庫檔案 也叫 切詞檔案”)。北京-天安門

  var:Sphinx運行中的記錄檔。

  產生Sphinx索引檔案   就會把sql查詢關聯語句結果取出來   扔到Sphinx資源套件裡產生一個二進位資源檔(儲存sql語句查詢結果)

1.配置

2.產生索引檔案

  

  檔案另存新檔  更換編碼

3.php操作Sphinx

  php操作Sphinx

    串連api:api檔案夾下Sphinx_api.php檔案, 引入api類 

    $sc = new SphinxClient(); 執行個體化Sphinx類

    $sc->SetServer(‘localhost‘,9312)  串連服務

    $sc->SetConnectTimeout(10) 串連的逾時時間

    $sc->SetMaxQueryTime(30)  最大的查詢時間

    $sc->SetArrayResult(true) 傳回值類型(數組)

    $sc->SetMatchMode(SPH_MATCH_ANY)  切詞方式

      (SPH_MATCH_ALL:完全符合才查詢【‘北京’,‘天安門’,‘北京天安門’】)

      (SPH_MATCH_ANY:單個匹配【‘三個詞其中一個就匹配’】)

      (SPH_MATCH_PHRASE:不切詞)

    $result = $sc->Query($post ,"*")  查詢索引檔案(關鍵字,select)

    搜尋後matches返回搜尋記錄

Sphinx 死文克斯 聯合Mysql實現中文全文索引

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.