搜尋
首頁後端開發php教程學習sphinx sphinx 中文 django sphinx python sphinx用法

在我們php開發中如何使用sphinx技術?

答:對應MySQL資料庫中的字段,就是將字段中的中文資訊拆分成多個詞語,然後對這些詞語建立索引。以後查詢的時候,先去查詢這些索引文件,再傳回這些符合條件的記錄的主鍵id,再根據主鍵id查詢MySQL資料庫,回傳記錄。

sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

什麼是sphinx? (百度百科)

注意:對於sphinx來說,單表千萬筆記錄,反應的時間都是毫秒等級的。

sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

注意:預設sphinx只支援英文和俄文

官網:

http://sphinxsearch.com/

由於Sphinx只支援以上兩種語言,所以有第三方公司為sphinx開發了中分分詞包,叫做coreseek

官網:

http://www.coreseek.cn/

sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

客戶案例:http://www.coreseek.cn/products/ft_powered/

注意兩點:

  1. sphinx是一個全文搜尋引擎,只支援俄文和英文

  2. 由於上面的原因,有專門的公司為其開發了中文分詞包,叫做coresesk。

  3. 中國有一家做的比較好的公司(海量分詞)

    http://www.hylanda.com/

    故事:http://home.hylanda.com/show_5_19.html

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

    實操

  4. 下載

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

    2. 建立一個大數據的表格(歌詞表)

    mysql > source d:/songs.sql

    檔案目錄:

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法指令:

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

    sphinx安裝-使用

    安裝

    千萬注意:sphinx的設定檔一定不能使用Windows的記事本開啟。 (BOM頭)

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

    API介面檔:可以用php呼叫該介面去操作sphinx伺服器端的索引檔。

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

  5. 修改設定檔

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

    索引文件

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

    記憶體設定:

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

    sphinxd配置:

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

  6. 建立索引

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

    設定檔中index後面的名稱

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

    建立索引後的目錄結構

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

    3. 實際使用

    a. 開啟sphinx的服務,可以使用幫助資訊查看如何使用

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

    使用:

  7. 可以單獨的讀取設定檔運行

  8. 也可以安裝成Windows的一個系統服務來運行

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

    啟動sphinx服務(讀取設定檔單次啟動)

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

    定義為系統服務後(安裝)

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

    使用

    1. 具體使用(sphinx流程可以見下圖)

    sphinx流程圖:

    sphinx儲存引擎:透過下面的步驟發現,發現php程式在做查詢的時候,必須先根據sphinx伺服器回傳主鍵ID,然後根據主鍵ID去查詢MySQL資料庫,最後再回傳資料庫。

    這個時候,可以這樣思考,將sphinx當作MySQL的一個儲存引擎使用,這個時候php程式就可以直接的去連接MySQL伺服器,MySQL伺服器去自身的sphinx儲存引擎裡面取得分詞後的資料。不需要連接一次sphinx伺服器了。這個儲存引擎叫做sphinxSE。

    http://blog.csdn.net/uestc_huan/article/details/6395145

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

  9. 簡單使用

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

  10. 使用

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

    sphinx 文档,sphinx 安装,sphinx cat,sphinx doc,sphinx 中文,django sphinx,python sphinx用法

以上就介紹了學習sphinx,包含了sphinx方面的內容,希望對PHP教程有興趣的朋友有所幫助。

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
使用PHP發送電子郵件的最佳方法是什麼?使用PHP發送電子郵件的最佳方法是什麼?May 08, 2025 am 12:21 AM

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

PHP中依賴注入的最佳實踐PHP中依賴注入的最佳實踐May 08, 2025 am 12:21 AM

使用依賴注入(DI)的原因是它促進了代碼的松耦合、可測試性和可維護性。 1)使用構造函數注入依賴,2)避免使用服務定位器,3)利用依賴注入容器管理依賴,4)通過注入依賴提高測試性,5)避免過度注入依賴,6)考慮DI對性能的影響。

PHP性能調整技巧和技巧PHP性能調整技巧和技巧May 08, 2025 am 12:20 AM

phpperformancetuningiscialbecapeitenhancesspeedandeffice,whatevitalforwebapplications.1)cachingwithapcureduccureducesdatabaseloadprovesrovessetimes.2)優化

PHP電子郵件安全性:發送電子郵件的最佳實踐PHP電子郵件安全性:發送電子郵件的最佳實踐May 08, 2025 am 12:16 AM

ThebestpracticesforsendingemailssecurelyinPHPinclude:1)UsingsecureconfigurationswithSMTPandSTARTTLSencryption,2)Validatingandsanitizinginputstopreventinjectionattacks,3)EncryptingsensitivedatawithinemailsusingOpenSSL,4)Properlyhandlingemailheaderstoa

您如何優化PHP應用程序的性能?您如何優化PHP應用程序的性能?May 08, 2025 am 12:08 AM

TOOPTIMIZEPHPAPPLICITIONSFORPERSTORANCE,USECACHING,數據庫imization,opcodecaching和SererverConfiguration.1)InlumentCachingWithApcutCutoredSatfetchTimes.2)優化的atabasesbasesebasesebasesbasesbasesbaysbysbyIndexing,BeallancingAndWriteExing

PHP中的依賴注入是什麼?PHP中的依賴注入是什麼?May 07, 2025 pm 03:09 PM

依賴性注射inphpisadesignpatternthatenhancesFlexibility,可檢驗性和ManiaginabilybyByByByByByExternalDependencEctenceScoupling.itallowsforloosecoupling,EasiererTestingThroughMocking,andModularDesign,andModularDesign,butquirscarecarefulscarefullsstructoringDovairing voavoidOverOver-Inje

最佳PHP性能優化技術最佳PHP性能優化技術May 07, 2025 pm 03:05 PM

PHP性能優化可以通過以下步驟實現:1)在腳本頂部使用require_once或include_once減少文件加載次數;2)使用預處理語句和批處理減少數據庫查詢次數;3)配置OPcache進行opcode緩存;4)啟用並配置PHP-FPM優化進程管理;5)使用CDN分發靜態資源;6)使用Xdebug或Blackfire進行代碼性能分析;7)選擇高效的數據結構如數組;8)編寫模塊化代碼以優化執行。

PHP性能優化:使用OpCode緩存PHP性能優化:使用OpCode緩存May 07, 2025 pm 02:49 PM

opcodecachingsimplovesphperforvesphpermance bycachingCompiledCode,reducingServerLoadAndResponSetimes.1)itstorescompiledphpcodeinmemory,bypassingparsingparsingparsingandcompiling.2)useopcachebachebachebachebachebachebachebysettingparametersinphametersinphp.ini,likeememeryconmorysmorysmeryplement.33)

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

Dreamweaver Mac版

Dreamweaver Mac版

視覺化網頁開發工具

WebStorm Mac版

WebStorm Mac版

好用的JavaScript開發工具

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。