Sphinx是一個基於SQL的全文檢索引擎,能夠結合MySQL,PostgreSQL作全文搜索,它能夠提供比數據庫自己更專業的搜索功能,使得應用程序更容易實現專業化的全文檢索。mysql
Sphinx特別爲一些腳本語言設計搜索API接口,如PHP,Python,Perl,Ruby等,同時爲MySQL也設計了一個存儲引擎插件。sql
Sphinx 單一索引最大可包含1億條記錄,在1千萬條記錄狀況下的查詢速度爲0.x秒(毫秒級)。數據庫
Sphinx建立索引的速度爲:建立100萬條記錄的索引只需 3~4分鐘,建立1000萬條記錄的索引能夠在50分鐘內完成,而只包含最新10萬條記錄的增量索引,重建一次只需幾十秒。bootstrap
Sphinx的主要特性包括:網絡
高速索引 (在新款CPU上,近10 MB/秒);分佈式
高速搜索 (2-4G的文本量中平均查詢速度不到0.1秒);ide
高可用性 (單CPU上最大可支持100 GB的文本,100M文檔);測試
提供良好的相關性排名 支持分佈式搜索;ui
提供文檔摘要生成;編碼
提供從MySQL內部的插件式存儲引擎上搜索 支持布爾,短語, 和近義詞查詢;
支持每一個文檔多個全文檢索域(默認最大32個);
支持每一個文檔多屬性;
支持斷詞;
支持單字節編碼與UTF-8編碼;
1 # 下載coreseek:coreseek 3.2.14 2 $ wget http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.14.tar.gz 3 $ tar xzvf coreseek-3.2.14.tar.gz 4 $ cd coreseek-3.2.14 5 6 #前提,需提早安裝操做系統基礎開發庫及mysql依賴庫以支持mysql數據源和xml數據源 7 #安裝mmseg 8 $ cd mmseg-3.2.14 9 $ ./bootstrap #輸出的warning信息能夠忽略,若是出現error則須要解決 10 $ ./configure --prefix=/usr/local/mmseg3 11 $ make && make install 12 $ cd .. 13 14 #安裝coreseek 15 $ cd csft-3.2.14 或者 cd csft-4.0.1 或者 cd csft-4.1 16 $ sh buildconf.sh #輸出的warning信息能夠忽略,若是出現error則須要解決 17 ./configure --prefix=/usr/local/coreseek --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg3/lib/ --with-mysql 18 19 #./configure --prefix=/coreseek/sphinx/coreseek --without-unixodbc --with-mmseg --with-mmseg-includes=/coreseek/sphinx/mmseg3/include/mmseg/ --with-mmseg-libs=/coreseek/sphinx/mmseg3/lib/ --with-mysql 20 ##若是提示mysql問題,能夠查看MySQL數據源安裝說明 21 $ make && make install 22 $ cd .. 23 24 ,測式coreseek 25 #測試mmseg分詞,coreseek搜索(須要預先設置好字符集爲zh_CN.UTF-8,確保正確顯示中文) 26 $ cd testpack 27 $ cat var/test/test.xml #此時應該正確顯示中文 28 $ /usr/local/mmseg3/bin/mmseg -d /usr/local/mmseg3/etc var/test/test.xml 29 $ /usr/local/coreseek/bin/indexer -c etc/csft.conf --all 30 $ /usr/local/coreseek/bin/search -c etc/csft.conf 網絡搜索 31 cd ../testpack 32 $ /usr/local/coreseek/bin/indexer -c etc/csft.conf 33 34 #如下爲正常狀況下的提示信息: 35 Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)] 36 Copyright (c) 2007-2010, 37 Beijing Choice Software Technologies Inc (http://www.coreseek.com) 38 39 using config file 'etc/csft.conf'... 40 total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg 41 total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg 42 43 $ /usr/local/coreseek/bin/search -c etc/csft.conf 44 #如下爲正常測試搜索時的提示信息:(csft-4.0版相似) 45 Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)] 46 Copyright (c) 2007-2010, 47 Beijing Choice Software Technologies Inc (http://www.coreseek.com) 48 49 using config file 'etc/csft.conf'... 50 index 'xml': query '': returned 3 matches of 3 total in 0.093 sec 51 52 displaying matches: 53 1. document=1, weight=1, published=Thu Apr 1 22:20:07 2010, author_id=1 54 2. document=2, weight=1, published=Thu Apr 1 23:25:48 2010, author_id=1 55 3. document=3, weight=1, published=Thu Apr 1 12:01:00 2010, author_id=2 56 57 words:
出現ERROR:
using config file '/usr/local/coreseek/etc/video.conf'...
indexing index 'video'...
ERROR: source 's_video': unknown type 'MySQL'; skipping.
ERROR: index 'video': failed to configure some of the sources, will not index.
total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
安裝mysql支持
yum install mysql-devel libxml2-devel expat-devel
從新編譯
編譯錯誤一
make[2]: *** [indexer] Error 1
make[2]: Leaving directory `/www/tmp/csft-3.1/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/www/tmp/csft-3.1/src'
make: *** [all-recursive] Error 1
In the meantime I've change the configuration file and set
#define USE_LIBICONV 0 in line 8179.修改configure 文件把 #define USE_LIBICONV 0 最後的數值由1改成0從新編譯。