coreseek,php,mysql全文检索部署(一)

安装环境:

Ubuntu 10.04.4      64位

mysql                    Ver 14.14 Distrib 5.1.69

php                        PHP 5.2.6 (cli)


coreseek安装需要预装的软件:

apt-get install make gcc g++ automake libtool mysql-client libmysqlclient15-dev   libxml2-dev libexpat1-dev


coreseek安装需要源码包:

wget http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.14.tar.gz


安装完成后的目录说明:

api:api接口和测试脚本

etc:配置文件

etc/pysource:python数据源脚本

var:运行数据

var/data:索引文件

var/log:搜索日志

var/test:测试源数据


1.安装mmseg   (支持中文分词)

root@CC-57:~# tar zxvf coreseek-3.2.14.tar.gz

root@CC-57:~# cd coreseek-3.2.14/mmseg-3.2.14/

root@CC-57:~/coreseek-3.2.14/mmseg-3.2.14# ./bootstrap         #输出的warning信息可以忽略,如果出现error则需要解决


root@CC-57:~/coreseek-3.2.14/mmseg-3.2.14# ./configure --prefix=/usr/local/mmseg3

root@CC-57:~/coreseek-3.2.14/mmseg-3.2.14# make && make install


2.安装coreseek   支持mysql数据源和xml数据源

root@CC-57:~/coreseek-3.2.14/mmseg-3.2.14# cd ../csft-3.2.14/

root@CC-57:~/coreseek-3.2.14/csft-3.2.14# sh buildconf.sh      #输出的warning信息可以忽略,如果出现error则需要解决

root@CC-57:~/coreseek-3.2.14/csft-3.2.14# ./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=/var/www/dream/mysql/

root@CC-57:~/coreseek-3.2.14/csft-3.2.14# make && make install


可能遇到的问题:


有的系统下可能出现:expected `;' before ‘CSphTokenizer_UTF8SpaceSeg’,

或者出现:configure: WARNING: unrecognized options: --with-mmseg, --with-mmseg-includes, --with-mmseg-libs

是因为你没有进行随后的sh buildconf.sh操作

生成当前系统对应的编译配置文件

需要使用以下指令:$ sh buildconf.sh

Linux环境下,如遇到pthread问题,请先直接执行以下指令在进行configur:$ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib$ export LD_LIBRARY_PATH

如果出现undefined reference to `libiconv'的类似错误,可以按照如下方法处理:

方法一:(Linux使用)## 直接执行:export LIBS="-liconv"

然后make clean,再次configure后,进行编译安装make && make install

方法二:

首先configure,然后vim src/makefile

在其中搜索lexpat,在其后加上 -liconv

修改后该行应该为:-lexpat -liconv -L/usr/local/lib

然后再次make && make install## 方法三:

首先configure,然后vim config/config.h

在其中搜索USE_LIBICONV,将其后的1修改为0

然后再次make && make install


3.测试mmseg分词,coreseek搜索(需要预先设置好字符集为zh_CN.UTF-8,确保正确显示中文)

root@CC-57:~/coreseek-3.2.14/testpack# export LANG=zh_CN.UTF-8       #设定系统字符集

root@CC-57:~/coreseek-3.2.14/testpack# locale

LANG=zh_CN.UTF-8

LANGUAGE=en_US:en

LC_CTYPE="zh_CN.UTF-8"

LC_NUMERIC="zh_CN.UTF-8"

LC_TIME="zh_CN.UTF-8"

LC_COLLATE="zh_CN.UTF-8"

。。。。

root@CC-57:~/coreseek-3.2.14/csft-3.2.14# cd ../testpack/

root@CC-57:~/coreseek-3.2.14/testpack# cat var/test/test.xml           #此时应该正确显示中文

root@CC-57:~/coreseek-3.2.14/testpack# /usr/local/mmseg3/bin/mmseg -d /usr/local/mmseg3/etc/ var/test/test.xml


root@CC-57:~/coreseek-3.2.14/testpack# /usr/local/coreseek/bin/indexer -c etc/csft.conf --all

报错:

/usr/local/coreseek/bin/indexer: error while loading shared libraries: libmysqlclient.so.15: cannot open shared object file: No such file or directory

解决办法:

root@CC-57:~/coreseek-3.2.14/testpack# ln -s /var/www/dream/mysql/lib/mysql/libmysqlclient.so.15 /usr/lib/

继续执行:

root@CC-57:~/coreseek-3.2.14/testpack# /usr/local/coreseek/bin/indexer -c etc/csft.conf --all

##以下为正常索引全部数据时的提示信息:(csft-4.0版类似)

Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]

Copyright (c) 2007-2011,

Beijing Choice Software Technologies Inc (http://www.coreseek.com)

using config file 'etc/csft.conf'...

indexing index 'xml'...

collected 3 docs, 0.0 MB

sorted 0.0 Mhits, 100.0% done

total 3 docs, 7585 bytes

total 0.010 sec, 739134 bytes/sec, 292.34 docs/sec

total 2 reads, 0.000 sec, 4.2 kb/call avg, 0.0 msec/call avg

total 7 writes, 0.000 sec, 3.1 kb/call avg, 0.0 msec/call avg


root@CC-57:~/coreseek-3.2.14/testpack# /usr/local/coreseek/bin/indexer -c etc/csft.conf var/test/test.xml

##以下为正常索引指定数据时的提示信息:(csft-4.0版类似)

Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]

Copyright (c) 2007-2011,

Beijing Choice Software Technologies Inc (http://www.coreseek.com)


using config file 'etc/csft.conf'...

WARNING: no such index 'var/test/test.xml', skipping.

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



root@CC-57:~/coreseek-3.2.14/testpack# /usr/local/coreseek/bin/search -c etc/csft.conf

##以下为正常测试搜索时的提示信息:(csft-4.0版类似)

Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]

Copyright (c) 2007-2011,

Beijing Choice Software Technologies Inc (http://www.coreseek.com)

using config file 'etc/csft.conf'...

index 'xml': query '': returned 3 matches of 3 total in 0.004 sec

displaying matches:

1. document=1, weight=1, published=Thu Apr  1 22:20:07 2010, author_id=1

2. document=2, weight=1, published=Thu Apr  1 23:25:48 2010, author_id=1

3. document=3, weight=1, published=Thu Apr  1 12:01:00 2010, author_id=2

words:


root@CC-57:~/coreseek-3.2.14/testpack# /usr/local/coreseek/bin/search -c etc/csft.conf -a Twittter

##以下为正常测试搜索关键词时的提示信息:(csft-4.0版类似)

Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]

Copyright (c) 2007-2011,

Beijing Choice Software Technologies Inc (http://www.coreseek.com)


using config file 'etc/csft.conf'...

index 'xml': query 'Twittter ': returned 1 matches of 1 total in 0.014 sec


displaying matches:

1. document=2, weight=1, published=Thu Apr  1 23:25:48 2010, author_id=1


words:

1. 'twittter': 1 documents, 3 hits



root@CC-57:~/coreseek-3.2.14/testpack# /usr/local/coreseek/bin/searchd -c etc/csft.conf

##以下为正常开启搜索服务时的提示信息:(csft-4.0版类似)

Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]

Copyright (c) 2007-2011,

Beijing Choice Software Technologies Inc (http://www.coreseek.com)


using config file 'etc/csft.conf'...

listening on all interfaces, port=9312


root@CC-57:~/coreseek-3.2.14/testpack# netstat -nuptl | grep :9312

tcp        0      0 0.0.0.0:9312            0.0.0.0:*               LISTEN      21818/searchd

如要停止搜索服务:

root@CC-57:~/coreseek-3.2.14/testpack# /usr/local/coreseek/bin/searchd -c etc/csft.conf --stop

Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]

Copyright (c) 2007-2011,

Beijing Choice Software Technologies Inc (http://www.coreseek.com)


using config file 'etc/csft.conf'...

stop: succesfully sent SIGTERM to pid 21818


4.通过以上步骤

coreseek已经安装测试完成,可以提供正常的xml数据源索引以及提供对应的搜索服务了


你可能感兴趣的:(PHP,coreseek,mysql全文检索部署)