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研发并独立发布,专攻中文搜索和信息处理领域,适用于行业/垂直搜索.论坛 ...
随机推荐
- 没有可用的软件包 xxx,但是它被其它的软件包引用了
在linux下apt安装软件,弹出这个错. 解决,更新下资源: sudo apt-get update
- api-doc-php
主要功能: 根据接口注释自动生成接口文档 演示地址 [Gitee Pages:]http://itxq.gitee.io/api-doc-php 开源地址: [GigHub:]https://gith ...
- 新手學python之新體驗
1. 使用縮進方式做為程式塊開始結束的標示,程式換行在行末尾加 "\" 2. 元祖(Tuple)數據類型,和List的不同是Tuple不能修改,優點是執行速度比List快,因為不能 ...
- iOS——学习网址收集
1 一个比系统自带的终端好用的软件:http://www.iterm2.com 2 学习和遇到技术问题可以去的网站: CocoaChina http://developer.cocoachi ...
- Overview to “Toon/Cel shading”
转自:https://blog.felixkate.net/2017/01/19/toon-shading/ For the last couple of weeks I often had disc ...
- hive 字符串截取
语法 :substr(字段,starindex,len) 下标从 1 开始 测试 ,) from siebel_cx_order limit ; -- -- -- -- -- -- -- -- -- ...
- k8s-ingress安装
一.编写nginx-ingress-controller.yaml文件 apiVersion: extensions/v1beta1 kind: Deployment metadata: name ...
- MATLAB 代码规范
标识符命名原则 标识符的名字应当直观,其长度应当符合"最小长度,最大信息量"原则 非矩阵变量 变量名应该以小写字母开头的大小写混合形式 譬如:shadowFadingTable,s ...
- vue 在发送axios请求时数据渲染问题
这是我请求的json格式的数据 一开始在vue用普通的数据渲染,更改为vue后使用v-for 发现没办法渲染上去了. obj.data就是以上数据. 必须加上这三行给this随意赋个值,神奇的事情就会 ...
- 基于Keras搭建MLP
Keras是一套基于Tensorflow.Theano及CNTK后端的高层神经网络API,可以非常友好地支持快速实验,本文从零开始介绍了如何使用Keras搭建MLP并给出两个示例. 基于Ubuntu安 ...