编译安装sphinx

来源:互联网 发布:淘宝网商城拉丁舞服饰 编辑:程序博客网 时间:2024/05/22 05:16
下载

解压缩
tar zxvf sphinx-2.1.2-release.tar.gz
cd sphinx-2.1.2-release

配置
./configure --prefix=/usr/local/sphinx--with-mysql=/usr/local/mysql

编译并安装
make
make install

复制配置文件
cp sphinx-min.conf.dist sphinx.conf

修改配置文件
sql_user 
              =root        #表示数据库的用户名
sql_attr_uint          =group_id    #:整数属性,以上group_id、date_added都可用此设置,使用SetFilter()过滤,
                              或者使用SetFilterRange()过滤;
                              SphinxSE之中,使用filter或者range过滤;
sql_attr_string        =content     #

sql_query_info         = SELECT * FROM documents WHEREid=$id  #命令行查询时,从数据库读取原始数据信息



生成全部索引
/usr/local/sphinx/bin/indexer --config/usr/local/sphinx/etc/sphinx.conf --all
若此时searchd守护进程已经启动,那么需要加--rotate参数:
/usr/local/sphinx/bin/indexer --config/usr/local/sphinx/etc/sphinx.conf --all --rotate

启动searchd守护进程
/usr/local/sphinx/bin/searchd --config/usr/local/sphinx/etc/sphinx.conf

使用search命令在命令行对索引进行检索
/usr/local/sphinx/bin/search --config/usr/local/sphinx/etc/sphinx.conf
/usr/local/sphinx/bin/search --config/usr/local/sphinx/etc/sphinx.conf -q number




参考地址
http://blog.163.com/zf_zhouf/blog/static/2000980262011910347176/
http://blog.csdn.net/cleanfield/article/details/7029860
http://lovealwaysonline.blog.163.com/blog/static/197692011201261485729837/
0 0