Sphinx 0.9.9/Coreseek 3.2的安装与基于MYSQL的配置

嘿嘿,新手,第一次写博客,不足之处请各位前辈指出,以便修正!

1、首先从coreseek官方网站上下载coreseek-3.2.14.tar.gz压缩包,进行解压

2、在安装coreseek前,先安装mmseg,以root身份安装,安装mmseg步骤如下:

cd coreseek-3.2.14/
cd mmseg-3.2.14/
./configure --prefix=/usr/local/mmseg/
make
make install

这里可能出现以下错误:

config.status: error: cannot find input file: `/ch/Download/netgen/Makefile.in'
make: *** [Makefile] 错误 1

可运行以下命令解决:

aclocallibtoolize --force 我运行后有一个错误,没管它。
automake --add-missing
autoconf
autoheader
make clean
./configure --prefix=/usr/local/mmseg3


然后就能通过了,再:

make && make install
$ /usr/local/mmseg3/bin/mmseg -d /usr/local/mmseg3/etc src/t1.txt
中文/x 分/x 词/x 测试/x
中国人/x 上海市/x

上面代码表示mmseg安装成功
2、安装coreseek
安装步骤如下:
cd ..
cd csft-3.2.14/
sudo
make
make install
如果出现以下错误,错误原因是你的mmseg的安装路径不对!
******************************************************************************
ERROR: cannot find libmmseg include files.

To disable libmmseg support, use --without-mmseg option.
******************************************************************************

如果make时出现以下警告,没关系,可忽略继续make install
make[2]: Leaving directory `/home/lexxe/meng/coreseek-3.2.14/csft-3.2.14/src'
make[1]: Leaving directory `/home/lexxe/meng/coreseek-3.2.14/csft-3.2.14/src'
Making all in test
make[1]: Entering directory `/home/lexxe/meng/coreseek-3.2.14/csft-3.2.14/test'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/lexxe/meng/coreseek-3.2.14/csft-3.2.14/test'
make[1]: Entering directory `/home/lexxe/meng/coreseek-3.2.14/csft-3.2.14'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/home/lexxe/meng/coreseek-3.2.14/csft-3.2.14'


然后make install就可以安装完成

3、配置
coreseek提供了很多接口,如PHP,MYSQL等,在~/coreseek-3.2.14/testpack/etc里都有配置文件的举例,我就以MYSQL为例,进行配置
将~/coreseek-3.2.14/testpack/etc下的csft_mysql.conf拷贝到coreseek的安装目录下的/etc下并从新命名为csft.conf
(1)进行源定义,如下:
#源定义
source mysql #源名称
{
type = mysql #从那里获得数据源,这里是MYSQL

sql_host = localhost #地址
sql_user = root #MYSQL的用户
sql_pass = root #MYSQL用户密码
sql_db = test #想要搜索的数据库名称
sql_port = 3306 #提供的端口
sql_query_pre = SET NAMES utf8

sql_query = SELECT id, group_id, UNIX_TIMESTAMP(date_added) AS date_added, title, content FROM documents
#sql_query第一列id需为整数
#title、content作为字符串/文本字段,被全文索引
sql_attr_uint = group_id #从SQL读取到的值必须为整数
sql_attr_timestamp = date_added #从SQL读取到的值必须为整数,作为时间属性

sql_query_info_pre = SET NAMES utf8 #命令行查询时,设置正确的字符集
sql_query_info = SELECT * FROM documents WHERE id=$id #命令行查询时,从数据库读取原始数据信息
}

(2)索引定义,如下:
#index定义
index mysql #索引名
{
source = mysql #对应的source名称
path = /usr/local/coreseek/var/data/sphinx #请修改为实际使用的绝对路径,例如:/usr/local/coreseek/var/...
docinfo = extern
mlock = 0
morphology = none
min_word_len = 1
html_strip = 0

#中文分词配置,详情请查看:http://www.coreseek.cn/products-install/coreseek_mmseg/
charset_dictpath = /usr/local/mmseg3/etc/ #BSD、Linux环境下设置,/符号结尾
#charset_dictpath = etc/ #Windows环境下设置,/符号结尾,最好给出绝对路径,例如:C:/usr/local/coreseek/etc/...
charset_type = zh_cn.utf-8
}
(3)测试:
索引:使用bin目录下的indexer,执行:indexer -c 配置文件的路径 index名称


# /usr/local/coreseek/bin/indexer -c etc/csft.conf --all ##--all表示全部索引
##Windows下面为bin\indexer -c etc\csft.conf --all
##以下为正常索引全部数据时的提示信息:部分数据信息根据实际数据情况变化
Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]
Copyright (c) 2007-2010,
Beijing Choice Software Technologies Inc (http://www.coreseek.com)

using config file 'etc/csft.conf'...
indexing index '索引名称'...
collected 3 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 3 docs, 7585 bytes
total 0.075 sec, 101043 bytes/sec, 39.96 docs/sec
total 2 reads, 0.000 sec, 5.6 kb/call avg, 0.0 msec/call avg
total 7 writes, 0.000 sec, 3.9 kb/call avg, 0.0 msec/call avg

如果出现以上对应的提示,则表示配置正确,可以正常索引;
也可以对csft.conf里定义的索引进行建立索引,如下:
/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/csft.conf mysql #mysql为csft.conf里的index名称
随后,启动搜索:使用bin目录下的searchd,执行:searchd -c 配置文件的路径 --console
# /usr/local/coreseek/bin/searchd -c etc/csft.conf --console
##Windows下面为bin\searchd -c etc\csft.conf --console
##以下为正常开启搜索服务时的提示信息:其中的port可以在配置文件中修改
Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]
Copyright (c) 2007-2010,
Beijing Choice Software Technologies Inc (http://www.coreseek.com)

using config file 'etc/csft.conf'...
listening on all interfaces, port=9312


OK!安装与配置完成!


 
 


   
   


   
   


   
   

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值