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从新编译。