2019独角兽企业重金招聘Python工程师标准>>>

一:安装sphinx步骤如下:

下载sphinx最新的2.2.11版本
cd /opt/sphinx
wget 下载地址
tar xzvf sphinx-2.2.11-release.tar.gz 
cd /opt/sphinx/sphinx-2.2.11-release
./configure --prefix=/opt/soft_install/sphinx/ --with-mysql=/usr/local/mysql
make && make install

安装成功后,会在目录:ls -lht /opt/soft_install/sphinx/下有四个文件夹
[root@XL_Php_Mysql sphinx-2.2.11-release]# ls -lht /opt/soft_install/sphinx/
总用量 16K
drwxr-xr-x 4 root root 4.0K 7月  22 12:05 var
drwxr-xr-x 2 root root 4.0K 7月  22 12:05 etc
drwxr-xr-x 3 root root 4.0K 7月  22 12:05 share
drwxr-xr-x 2 root root 4.0K 7月  22 12:05 bin

进入etc目录,拷贝配置文件, cp  sphinx-min.conf.dist  sphinx.conf  (这里不拷贝sphinx.conf.dist ,因为这文件只是比前者多了一堆注释)

其实只需要安装coreseek即可,不需要安装sphinx。

安装coreseek
首先下载软件,打开 官网 coreseek.cn(不过该网站已经打不开了,只能去其他地方下载,我是从csdn上下的,花了5积分,好心疼)
下载coreseek-4.1-beta.tar.gz(csdn下载)
cd /opt/coreseek
wget 下载地址
tar xzvf coreseek-4.1-beta.tar.gz
里有3个文件夹 一个是mmseg中文分词包 一个是csft(其实就是sphinx)包,一个是测试包testpack,只需安装前两个即可。

创建安装目录:
mkdir /opt/soft_install/coreseek

返回coreseek mmseg目录,开始首先安装mmseg
cd /opt/coreseek/coreseek-4.1-beta/mmseg-3.2.14/
首先安装mmseg中文分词
./configure --prefix=/opt/soft_install/coreseek/mmseg

编译时可能会报错config.status: error: cannot find input file: src/Makefile.in
通过automake来解决
首先检查是否安装了libtool如果没有 
yum -y install libtool
automake
如果automake报错 原因可能是下列
Libtool library used but `LIBTOOL' is undefined
The usual way to define `LIBTOOL' is to add `AC_PROG_LIBTOOL'
to `configure.ac' and run `aclocal' and `autoconf' again.
If `AC_PROG_LIBTOOL' is in `configure.ac', make sure
its definition is in aclocal's search path.

如果以上步骤都没成功,那么试下以下办法(把下面的命令都执行一遍,就好了)
aclocal
libtoolize -f (等于libtoolize --force)
automake -a (等于automake -add-missing)
autoconf
autoheader
make clean

执行完上述语句后,继续执行安装命令:
./configure --prefix=/opt/soft_install/coreseek/mmseg
此时会出现安装成功的命令显示:
------------------------------------------------------------------------
Configuration:

Source code location:       .
  Compiler:                   gcc
  Compiler flags:             -g -O2
  Host System Type:           x86_64-redhat-linux-gnu
  Install path:               /opt/soft_install/coreseek/mmseg

See config.h for further configuration information.
------------------------------------------------------------------------

运行安装命令:
make && make install

运行结束后,在安装目录:/opt/soft_install/coreseek/mmseg/会有四个文件产生:
[root@XL_Php_Mysql mmseg-3.2.14]# ls -lht /opt/soft_install/coreseek/mmseg/
总用量 16K
drwxr-xr-x 2 root root 4.0K 7月  22 12:31 etc
drwxr-xr-x 3 root root 4.0K 7月  22 12:31 include
drwxr-xr-x 2 root root 4.0K 7月  22 12:31 bin
drwxr-xr-x 2 root root 4.0K 7月  22 12:31 lib
测试是否安装成功:
/opt/soft_install/coreseek/mmseg/bin/mmseg -d /opt/soft_install/coreseek/mmseg/etc/ /opt/coreseek/coreseek-4.1-beta/mmseg-3.2.14/src/t1.txt

接着继续安装csft:
进入原码目录:
cd /opt/coreseek/coreseek-4.1-beta/csft-4.1
sh buildconf.sh
./configure --prefix=/opt/soft_install/coreseek/csft --with-mysql=/usr/local/mysql --with-mmseg=/opt/soft_install/coreseek/mmseg --with-mmseg-includes=/opt/soft_install/coreseek/mmseg/include/mmseg/ --with-mmseg-libs=/opt/soft_install/coreseek/mmseg/lib/

make && make install

安装成功后,在安装目录下有四个目录:
[root@XL_Php_Mysql coreseek]# ls -lht /opt/soft_install/coreseek/csft/
总用量 16K
drwxr-xr-x 4 root root 4.0K 7月  22 12:43 var
drwxr-xr-x 2 root root 4.0K 7月  22 12:43 etc
drwxr-xr-x 3 root root 4.0K 7月  22 12:43 share
drwxr-xr-x 2 root root 4.0K 7月  22 12:43 bin

安装完毕后 注意 coreseek 中的配置文件也是csft.conf 而不是 sphinx.conf
cd /opt/soft_install/coreseek/csft/etc/
cp sphinx.conf.dist csft.conf
vim csft.conf

测试是否安装成功
/opt/soft_install/coreseek/csft/bin/indexer -c /opt/soft_install/coreseek/csft/etc/csft.conf 
如果出现报错:/opt/soft_install/coreseek/csft/bin/indexer: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
则需要将文件:
32位系统:ln -s /usr/local/mysql/lib/libmysqlclient.so.18.1.0 /usr/lib/libmysqlclient.so.18
64位系统:ln -s /usr/local/mysql/lib/libmysqlclient.so.18.1.0 /usr/lib64/libmysqlclient.so.18

配置、测试mysql数据源搜索
cp /opt/coreseek/coreseek-4.1-beta/testpack/etc/csft_mysql.conf /opt/soft_install/coreseek/csft/etc/
[root@XL_Php_Mysql testpack]# ls -lht /opt/soft_install/coreseek/csft/etc/
总用量 68K
-rwxr-xr-x 1 root root 2.8K 7月  22 15:42 csft_mysql.conf
-rw-r--r-- 1 root root  26K 7月  22 12:43 csft.conf
-rw-r--r-- 1 root root  903 7月  22 12:43 example.sql
-rw-r--r-- 1 root root  26K 7月  22 12:43 sphinx.conf.dist
-rw-r--r-- 1 root root 1.2K 7月  22 12:43 sphinx-min.conf.dist

mysql -uroot -p test < /opt/coreseek/coreseek-4.1-beta/testpack/var/test/documents.sql 
创建索引数据库账户
mysql> grant all privileges on test.* to sphinxdbuser@"%" identified by "sphinx07test";
mysql> grant all privileges on recruitment_system.* to sphinxdbuser@"%" identified by "sphinx07test";
mysql> flush privileges;

5.2 启动搜索服务
启动搜索服务,这里选择后台运行的方式
# /opt/soft_install/coreseek/csft/bin/indexer -c /opt/soft_install/coreseek/csft/etc/csft_mysql.conf --all
# /opt/soft_install/coreseek/csft/bin/searchd -c /opt/soft_install/coreseek/csft/etc/csft_mysql.conf
以在log中记录每个查询的io和cpu状态的方式启动搜索服务
# /opt/soft_install/coreseek/csft/bin/searchd  --iostats --cpustats -c /opt/soft_install/coreseek/csft/etc/csft_mysql.conf

停止搜索服务
# /opt/soft_install/coreseek/csft/bin/searchd -c /opt/soft_install/coreseek/csft/etc/csft_mysql.conf --stop

查看搜索服务状态
# /opt/soft_install/coreseek/csft/bin/searchd -c /opt/soft_install/coreseek/csft/etc/csft_mysql.conf --status

5.3 本机搜索测试
# /opt/soft_install/coreseek/csft/bin/search -c /opt/soft_install/coreseek/csft/etc/csft_mysql.conf -a 百度成立

停止mysql,观察以上本机搜索测试是否正常
# /etc/init.d/mysqld stop

启动mysql,观察以上本机搜索测试是否正常
# /etc/init.d/mysqld start

5.4 异机php客户端api调用测试
API路径:/opt/coreseek/coreseek-4.1-beta/testpack/api/

拷贝test.php 和sphinxapi.php到支持php环境的机器,然后修改数据库地址,账号,密码等配置,测试如下:

# php test.php  中国  
Query '中国 ' retrieved 1 of 1 matches in 0.016 sec.
Query stats:
    '中国' found 17 times in 1 documents

运行时可能会出现错误:
Warning: assert() has been disabled for security reasons in /opt/test_coreseek/sphinxapi.php on line 182
则修改:
vi /etc/php.ini 
disable_functions = 该列去除assert,
重启php-fpm
/etc/init.d/php-fpm restart
再次运行即可。

转载于:https://my.oschina.net/u/435872/blog/1489067

sphinx+coreseek创建中文分词索引相关推荐

  1. Lucene 5.2.1 + jcseg 1.9.6中文分词索引(Lucene 学习序列2)

    Lucene 5.2.1 + jcseg 1.9.6中文分词索引(Lucene 学习序列2) jcseg是使用Java开发的一个开源的中文分词器,使用流行的mmseg算法实现.是一款独立的分词组件,不 ...

  2. 全文索引JAVA_全文索引Sphinx和sphinx的中文分词

    网站需要做全文索引,所以研究了一下sphinx 1 Sphinx是什么 Sphinx是由俄罗斯人Andrew Aksyonoff开发的一个全文检索引擎.意图为其他应用提供高速.低空间占用.高结果 相关 ...

  3. Coreseek-带中文分词的Sphinx

    Sphinx并不支持中文分词, 也就不支持中文搜索, Coreseek = Sphinx + MMSEG(中文分词算法) 1.下载 1).到官网下载 2).解压后有三个文件夹 csft-3.2.14: ...

  4. Sphinx-for-chines中文分词安装配置及API调用

    这几天项目中需要重新做一个关于商品的全文搜索功能,于是想到了用Sphinx,因为需要中文分词,所以选择了Sphinx for chinese,当然你也可以选择coreseek,建议这两个中选择一个,暂 ...

  5. Lucene全文检索_分词_复杂搜索_中文分词器

    1 Lucene简介 Lucene是apache下的一个开源的全文检索引擎工具包. 1.1 全文检索(Full-text Search)  1.1.1 定义 全文检索就是先分词创建索引,再执行搜索的过 ...

  6. 大数据(7z)Scala手写中文分词

    文章目录 1.手写中文分词极简代码 2.中文分词+Spark词频统计 3.中文分词+Spark文本分类 4.HMM分词(不带词典) 5.HMM分词 1.手写中文分词极简代码 徒手编写Scala中文分词 ...

  7. 基于php的Sphinx以及coreseek的全文搜索,中文分词的使用(一)

    基于php的Sphinx以及coreseek的全文搜索,中文分词的使用(一) ##1.sphinx简介 1.什么是sphinx Sphinx是由俄罗斯人Andrew Aksyonoff开发的一个全文检 ...

  8. php mmseg,coreseek+sphinx+mmseg中文分词安装

    由于官网挂了,找资源 下载coreseek+sphinx+mmseg中文分词安装费了很多时间 开始是在github上一阵狂搜,找了几个都安装失败,后来在csdn上找到资源,一阵折腾之后安装成功 准备工 ...

  9. sphinx+coreseek+php扩展--用php程序实现中文拆词

    ##################### 一  mariadb 安装 ##############                     使用的是yum安装 略 ################# ...

最新文章

  1. VMM2012应用指南之4-向VMM中添加Hyper-V主机与应用服务器
  2. 从零开始单排学设计模式「UML类图」定级赛 1
  3. matlab修改矩阵元素,怎么修改矩阵中的某些元素 或者简单点说保留矩阵中的元素...
  4. C# MD5摘要算法、哈希算法
  5. 《Java技术》第九次作业计科1501赵健宇-IO
  6. ios14.3开发之使用纯代码创建UITabbarController
  7. 《剑指offer》-整数中1出现的次数
  8. 页面监听,一段时间内不操作网页,就自动跳转到登录页
  9. 织梦服务器系统win10,WIN服务器爆破DEDECMS后台目录
  10. mysql sqlite 性能优化_MySQL和Sqlite3性能测试
  11. 前端笔记-thymeleaf获取及回显input标签type=date
  12. 18 PP配置-生产计划-检查 MRP 元素的文本
  13. 个人企业作品网站导航页源码
  14. 人工智能 - paddlepaddle飞桨 - 深度学习基础教程 - 语义角色标注
  15. c语言找出递增子数组的长度,编程之美2.16 数组中最长递增子序列的长度
  16. 【百度地图】——利用三级联动加载百度地图
  17. c++中double类型控制小数位数
  18. mysql 配置root密码_Mysql安装与配置调优及修改root密码的方法
  19. Atitit web 3.0(web技术)展望与实现 和语义网络 目录 1. 为了说明Web 3.0,我们需要回顾Web历史上的重要浪潮。 2 1.1. 2.Web 2.0:任何人可以参与。Web
  20. Android设置Textview字体样式

热门文章

  1. liunx之tar 命令
  2. ORM映射框架总结--数据操作(五)
  3. Proximal Algorithms 3 Interpretation
  4. JqueryQrcode生成二维码不支持中文的解决办法
  5. Python IDE专用编辑器PyCharm下载及配置安装过程(Ubuntu环境)
  6. -webkit-overflow-scrolling:touch
  7. 2010-11季,关注波士顿凯尔特人的10个理由
  8. Svchost.exe病毒
  9. 比特币现金vs莱特币,谁将夺得小额支付市场?
  10. 004-什么是软件测试?软件测试的目的与原则