coreseek(Sphinx)详细操作教程,攻略大全,绝对原创,转载必究,搜索引擎技术攻略,全文索引技术详解

php教程11年前 (2014-08-06)16800

Sphinx(斯芬克司)是一个基于SQL的全文检索引擎,可以结合MySQL,PostgreSQL做全文搜索,它可以提供比数据库本身更专业的搜索功能,使得应用程序更容易实现专业化的全文检索。Sphinx特别为一些脚本语言设计搜索API接口,如Java,PHP,Python,Perl,Ruby等,同时为MySQL也设计了一个存储引擎插件

sphinx是国外的一款搜索软件。

coreseek是在sphinx的基础上,增加了中文分词功能,换句话说,就是支持了中文。


window下coreseek操作教程:
http://www.coreseek.cn/products-install/install_on_windows/
下载coreseek-4.1-win32.zip解压到e:/
coreseek-4.1-win32重命名为coreseek
E:\coreseek\etc\csft_mysql.conf复制一份到
E:\coreseek\bin下,并重命名为csft.conf(这里主要修改配置文件csft.conf)


win+R 输入cmd enter
先安装
e:\coreseek\bin\searchd --install --config e:\coreseek\bin\csft.conf  --servicename SphinxSearch


测试配置是否可用:E:\coreseek\bin\indexer -c E:\coreseek\bin\csft.conf


开启coreseek命令
E:\coreseek\bin\searchd -c E:\coreseek\bin\csft.conf

.停止搜索服务
E:\coreseek\bin\searchd -c E:\coreseek\bin\csft.conf --stop

创建更新索引(每次重新创建索引后必须重启服务器SphinxSearch)
E:\coreseek\bin\indexer -c E:\coreseek\bin\csft.conf --all --rotate
net start SphinxSearch //启动SphinxSearch服务
net stop SphinxSearch //停止SphinxSearch服务

安装完成后可进行测试
测试 英文搜索
E:\coreseek\bin\search -c E:\coreseek\bin\csft.conf DK88

E:\coreseek\bin\search -c E:\coreseek\bin\csft.conf 深圳

echo 深圳冷却枪 | iconv -f gbk -t utf-8 | search -c bin\csft.conf --stdin | iconv -f utf-8 -t gbk
如要停止搜索服务,请使用ctrl+C停止


linux CentOS release 5.4下coreseek操作教程:

coreseek安装需要预装的软件:yum install gcc make gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel expat-devel
在linux下右键打开终端必须安装好mysql
下载coreseek-4.1-beta.tar.gz到csft
[root@localhost ~]# wget http://www.coreseek.cn/uploads/csft/4.0/coreseek-4.1-beta.tar.gz

解压缩到当前目录
rm -rf coreseek-4.1-beta
[root@localhost ~]# tar xzvf coreseek-4.1-beta.tar.gz
cd coreseek-4.1-beta

里面有三个文件夹先安装mmseg(linux 下sphinx的中文分词包mmseg安装 )
[root@localhost ~]# cd mmseg-3.2.14

输出的warning信息可以忽略
[root@localhost mmseg-3.2.14]# ./bootstrap   

[root@localhost mmseg-3.2.14]#./configure --prefix=/usr/local/mmseg3


[root@localhost mmseg-3.2.14]# make

[root@localhost mmseg-3.2.14]# make install

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.9.2.tar.gz

安装coreseek
cd coreseek-4.1-beta
[root@localhost mmseg-3.2.14]# cd csft-4.1

[root@localhost csft-4.1]# sh buildconf.sh


[root@localhost csft-4.1]# ./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

[root@localhost csft-4.1]# ./configure --prefix=/usr/local/coreseek --without-python --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg3/lib/ --with-mysql

[root@localhost csft-4.1]# make
[root@localhost csft-4.1]# make install

如何不出错安装完成
测试mmseg分词,coreseek搜索
cd coreseek-4.1-beta
cd testpack
更改服务器编码(中文能正确显示)
locale
vi /etc/sysconfig/i18n
LANG="zh_CN"

[root@localhost testpack]#  cat var/test/test.xml

[root@localhost testpack]# /usr/local/mmseg3/bin/mmseg -d /usr/local/mmseg3/etc var/test/test.xml

创建索引文件
[root@localhost testpack]# /usr/local/coreseek/bin/indexer -c etc/csft.conf --all
如有错误执行:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH

搜索测试
[root@localhost testpack]# /usr/local/coreseek/bin/search -c etc/csft.conf
/usr/local/coreseek/bin/indexer -c etc/csft.conf xml
修改coreseeek配置文件
/usr/local/coreseek/testpack/etc/csft.conf
之后重新建立索引
[root@localhost testpack]# /usr/local/coreseek/bin/indexer -c etc/csft.conf --all
创建自己的配置文件
# cd /usr/local/coreseek/etc
# cp sphinx.conf.dist csft.conf
# vi csft.conf
导入测试数据库
$ mysql -admin test < /usr/local/coreseek/etc/example.sql
/usr/server/mysql/bin/mysql -u admin -p  test < /usr/local/coreseek/etc/example.sql

运行indexer 为你的数据创建全文索引:
cd /usr/local/coreseek/etc
/usr/local/coreseek/bin/indexer --all
检索你新创建的索引
cd /usr/local/coreseek/etc
/usr/local/coreseek/bin/search co2
如果要从PHP脚本检索索引,你需要:
1.运行守护进程searchd,PHP脚本需要连接到searchd上进行检索:
$ cd /usr/local/coreseek/etc
$ /usr/local/coreseek/bin/searchd
2. 运行PHP API 附带的test 脚本(运行之前请确认searchd守护进程已启动):
$ cd /源代码目录/coreseek/api
$ php test.php test

搜索测试
cd /usr/local/coreseek/
/usr/local/coreseek/bin/search -c etc/csft.conf
ps aux |grep searchd
lsof -i:9312
启动搜索 /usr/local/coreseek/bin/searchd -c etc/csft.conf --console
停止搜索服务 /usr/local/coreseek/bin/searchd -c etc/csft.conf --stop
停止搜索服务 /usr/local/coreseek/bin/search -c etc/csft.conf --stop
要更新索引 /usr/local/coreseek/bin/indexer -c etc/csft.conf --all --rotate

“coreseek(Sphinx)详细操作教程,攻略大全,绝对原创,转载必究,搜索引擎技术攻略,全文索引技术详解” 的相关文章

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。