歡迎來到小豬圈!

Showing posts with label Sphinx. Show all posts
Showing posts with label Sphinx. Show all posts

2009-07-26

在 Windows 下編譯 Sphinx PHP 擴充模組

  • PECL :: Package :: sphinx 下載的原始碼,還無法直接編譯,從 config.w32 看來還需要 libsphinxclient.lib 和 sphinxclient.h。
  • 雖然從 Sphinx 中 (在原始碼的 api\libsphinxclient 目錄裡) 自行編譯了 libsphinxclient.lib ,但還是派不上用場。
  • 後來是修改了 config.w32 ,把這行:
    EXTENSION("sphinx", "sphinx.c");
    改寫成
    EXTENSION("sphinx", "sphinx.c sphinxclient.c");
    加在一起編譯才成功的。
  • Sphinx PHP Extension 似乎沒辨法編成獨立的 DLL 檔。將上述那行加上第三個參數為 true 就行了:
    EXTENSION("sphinx", "sphinx.c sphinxclient.c", true);
  • Sphinx 原始碼也有提供 PHP 腳本版本的 API (api/sphinxapi.php) ,直接 include 即可。

2009-07-25

Sphinx 全文檢索引擎

  • Sphinx 0.9.8.1 加上 MySQL 5.1 在建立索引時會出現 column number 1 has no name 的錯誤訊息,改用目前最新 Sphinx 0.9.9 就行了。
  • 安裝成 Windows Service 時要明確指定 sphinx.conf 的路徑:
    searchd.exe --install --config C:\sphinx\sphinx.conf --servicename SphinxSearch
    不然會無法啟動並出現 service terminated unexpectedly 錯誤訊息。
  • 另外也要記得建立 log 、 query_log 、 pid_file 所指定的目錄。

  1. 下載 Sphinx 並壓縮至 C:\sphinx
  2. 依 sphinx.conf.in 或 sphinx-min.conf.in 編輯設定檔,並另存為 sphinx.conf 。
  3. 將工作目錄移至 cd \sphinx\bin
  4. 安裝成 Windows Services
    searchd.exe --install --config C:\sphinx\sphinx.conf --servicename SphinxSearch
  5. 建立索引
    indexer.exe --config C:\sphinx\sphinx.conf --all
  6. 測試搜尋,假設搜尋目標為 target-word
    search.exe --config C:\sphinx\sphinx.conf --any target-word
  7. 若要移除 Windows Services
    searchd.exe --delete --servicename SphinxSearch

標籤分類

Labels

Google Analytics Tracking Code

About Me

My photo
Keelung, R.O.C, Taiwan
一個不學無術、混吃等死的傢伙…