sphinx中文版Coreseek中文检索引擎安装和使用方法(Linux)
sphinx中文版Coreseek中文检索引擎安装和使用方法(Linux)
1. 安装必要的编译工作支持
安装coreseek之前需要安装这些工具,当然使用yum安装你的机子需要先保证已经联网
yum install make gcc g++ gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel expat-devel
2. 下载coreseek和编译安装
$ wget http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.14.tar.gz
$ tar xzvf coreseek-3.2.14.tar.gz
$ cd coreseek-3.2.14 ##安装mmseg中文分词
$ cd mmseg-3.2.14
$ ./bootstrap #输出的warning信息可以忽略,如果出现error则需要解决
$ ./configure --prefix=/usr/local/mmseg3
$ make && make install
$ cd .. ##安装coreseek
$ cd csft-3.2.14
$ sh buildconf.sh #输出的warning信息可以忽略,如果出现error则需要解决
$ ./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 ##如果提示mysql问题,可以查看MySQL数据源安装说明,注意--prifix后面的路径要和自己安装的路径一致
$ make && make install
$ cd ..
3. 配置MYSQL数据源
cp /usr/local/coreseek/etc/sphinx.conf.dist /usr/local/coreseek/etc/sphinx.conf
vi /usr/local/coreseek/etc/sphinx.conf
source news
{
type = mysql
sql_host = localhost
sql_user = root
sql_pass =123456
sql_db = test
sql_port =3306
sql_sock =/tmp/mysql.sock
sql_query_pre = SET NAMES utf8
sql_query_pre = REPLACE INTO sph_counter SELECT 1, MAX(id) FROM news
sql_query = SELECT id, contents, intro, title FROM news WHERE id<=( SELECT max_doc_id FROM sph_counter WHERE counter_id=1)
}
#设置增量索引,数据量较小时,也可以不设置而定时重新生成索引
source increment : news
{
sql_query_pre = SET NAMES utf8
sql_query = SELECT id, contents, intro, title FROM news WHERE id >( SELECT max_doc_id FROM sph_counter WHERE counter_id=1)
#这是增量索引的数据源sql。和上面保持一致,唯一的变化,就是where条件之后,这里查询的是大于上次重新生成索引的id,即:刚刚添加的数据
} index news
{
source = news
path =/usr/local/coreseek/var/data/news docinfo =extern
mlock =0
morphology = none
charset_dictpath =/usr/local/mmseg3/etc/
charset_type = zh_cn.utf-8
} index increment : news
{
source = increment
path =/usr/local/coreseek/var/data/increment
charset_dictpath =/usr/local/mmseg3/etc/
charset_type = zh_cn.utf-8
} indexer
{ mem_limit =128M
}
searchd
{
log =/usr/local/coreseek/var/log/searchd.log
read_timeout =5
client_timeout =300
max_children =30
pid_file =/usr/local/coreseek/var/log/searchd.pid
max_matches =1000
seamless_rotate =1
preopen_indexes =0
unlink_old =1
mva_updates_pool =1M
max_packet_size =8M
max_filter_values =4096
}
说明:如果想配置多个数据源,在配置文件中添加source和index即可,可以像增量那样添加,但不需要后面的 : news,就可以了,需要注意的是在sph_counter即可以数据统计表中,需要使用不同的id来区分不同的数据表
4.生成索引命令
生成索引
/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf --all --rotate
说明:这时sph_counter 表里会增加一条记录。存放的就是你内容表中的最大id。如果想要生成单个数据源的索引, /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf news --rotate(这条命令只生成news的索引)
开启后台进程
/usr/local/coreseek/bin/searchd -c /usr/local/coreseek/etc/sphinx.conf
说明:这时候对Mysql数据源进行搜索的话其实已经是有数据的。
增量索引
/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf increment --rotate
说明:这里增量索引的名称要换成自己对应的增量索引的名称
合并索引
/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf --merge news increment --rotate
说明:合并索引后,news索引此时可以检索到所有的数据,但是sph_counter表中最大id是没有变的,因此还需要在一定的时间内再次重新生成所有的索引
为了保持数据的完整性,重新生成索引
/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf --all --rotate
5.执行定时任务,更新增量索引、重新生成索引
*/1****/bin/sh /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf increment --rotate
*/5****/bin/sh /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf --merge news increment --rotate
301*** /bin/sh /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf --all --rotate
6.php操作coreseek
6.php安装sphinx扩展
#cd /usr/local/coreseek-3.2.14/csft-3.2.14/api/libsphinxclient
#./configure --prefix=/usr/local/sphinxclient
#configure: creating ./config.status
#config.status: creating Makefile
#config.status: error: cannot find input file:Makefile.in #报错configure失败 //处理configure报错
编译过程中报了一个config.status: error: cannot find input file: src/Makefile.in这个的错误,然后运行下列指令再次编译就能通过了:
# aclocal
# libtoolize --force
# automake --add-missing
# autoconf
# autoheader
# make clean //从新configure编译
# ./configure
# make && make install [第二步] 安装sphinx的PHP扩展
# wget http://git.php.net/?p=pecl/search_engine/sphinx.git;a=snapshot;h=9a3d08c67af0cad216aa0d38d39be71362667738;sf=tgz
# tar zxvf sphinx-9a3d08c.tar.gz
# cd sphinx-9a3d08c
# /usr/local/php/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config --with-sphinx=/usr/local/sphinxclient
# make && make install
extension = sphinx.so
/etc/init.d/php-fpm restart
sphinx中文版Coreseek中文检索引擎安装和使用方法(Linux)的更多相关文章
- Linux下PHP+MySQL+CoreSeek中文检索引擎配置
说明: 操作系统:CentOS 5.X 服务器IP地址:192.168.21.127 Web环境:Nginx+PHP+MySQL 站点根目录:/usr/local/nginx/html 目的:安装co ...
- CoreSeek中文检索引擎
目的:安装coreseek中文检索引擎,配置MySQL数据库访问接口,使用PHP程序实现中文检索. CoreSeek官方网站: http://www.coreseek.cn/ http://www.c ...
- win7下PHP+MySQL+CoreSeek中文检索引擎配置
1.Windows下的coreseek安装测试 (64位win7旗舰版) 官方参考:http://www.coreseek.cn/products-install/install_on_windows ...
- Coreseek + Sphinx + Mysql + PHP构建中文检索引擎
首先明确几个概念 Sphinx是开源的搜索引擎,它支持英文的全文检索.所以如果单独搭建Sphinx,你就已经可以使用全文索引了.但是往往我们要求的是中文索引,怎么做呢?国人提供了一个可供企业使用的,基 ...
- ubuntu-10.04的测试环境 安装测试 Coreseek开源中文检索引擎-Sphinx中文版
主要参考文档:http://www.coreseek.cn/products-install/install_on_bsd_linux/ 一. 32位版本: coreseek安装需要预装的软件: ap ...
- 【整理】Linux下中文检索引擎coreseek4安装,以及PHP使用sphinx的三种方式(sphinxapi,sphinx的php扩展,SphinxSe作为mysql存储引擎)
一,软件准备 coreseek4.1 (包含coreseek测试版和mmseg最新版本,以及测试数据包[内置中文分词与搜索.单字切分.mysql数据源.python数据源.RT实时索引等测 ...
- 开源中文检索引擎Coreseek简单使用
Coreseek结合MySQL使用简单示例,如下所示: echo 北京 | iconv -f gbk -t utf-8 | search -c D:\web\coreseek\etc\csft_mys ...
- 【PHP高效搜索专题(1)】sphinx&Coreseek的介绍与安装
我们已经知道mysql中带有"%keyword%"条件的sql是不走索引的,而不走索引的sql在大数据量+大并发量的时候,不仅效率极慢还很有可能让数据库崩溃.那我们如何通过某些关键 ...
- 0622centos下coreseek安装及使用方法
Coreseek 中文全文检索引擎 Coreseek 是一款中文全文检索/搜索软件,以GPLv2许可协议开源发布,基于Sphinx研发并独立发布,专攻中文搜索和信息处理领域,适用于行业/垂直搜索.论坛 ...
随机推荐
- Consider defining a bean of type 'com.*.*.feign.*FeignClient' in your configuration.
Description: Field *FeignClient in com.*.*.service.* required a bean of type '***********' that coul ...
- vs查找替换功能打不开!
其实解决办法很简单啊 vs--窗口--重置窗口布局
- windows系统下设置mtu值的方法
说起 MTU 值,可能许多朋友连听都没听说过.简单来说,我们上网时所进行的操作,都是通过传输一个又一个“数据包”来实现的,而 MTU 值就是用来设定可传输数据包的最大尺寸的.很显然,MTU 值设置得过 ...
- 转 Oracle 同一个字段的两值进行加减计算
https://www.cnblogs.com/hjianguo/p/6041617.html 如 病人ID 入院日期 出院日期 00001 2016 ...
- oracle 统计成绩
set serveroutput on; declare cursor c1 is select dno,dname from dep; pdno dep.dno%TYPE; pdname dep.d ...
- word中的总页数不包括封面、目录
删除分隔符:选项-显示-显示所有格式标记
- 相同数据中选择id最大数据 的sql
select max(id)id ,name, age from tablename group by name, age
- EF Core使用遇到的问题
目录 EF Core速度问题 问题描述 EF使用方法1,每一行存储一次(400条/s) EF使用方法2,链接不释放 (40条/s) EF使用方法3,多次add,一次SaveChanges(400条/s ...
- RabbitMQ使用及与spring boot整合
1.MQ 消息队列(Message Queue,简称MQ)——应用程序和应用程序之间的通信方法 应用:不同进程Process/线程Thread之间通信 比较流行的中间件: ActiveMQ Rabbi ...
- Oracle Spatial分区应用研究之五:不同分区粒度+本地空间索引效率对比
1.实验目的 若使用本地空间索引,不同分区粒度将产生不同索引组织,其索引分区个数.大小.R-TREE树结构均不相同.那么,在什么分区粒度下的本地空间索引效率较高呢? 2实验数据 实验数据为全国2531 ...