一、Centos下基于sphinx的开源搜刮引擎coreseek的安装
coreseek是一款基于sphinx开源的搜刮引擎,由于sphinx只支持英文和俄文(即只能举行英文分词和俄文分词),以是假如要利用sphinx做中文搜刮的话,须要本身独立去导入中文词库。而coreseek里集成了中文词库模块mmseg,以是直接利用coreseek会方便很多。
Coreseek如今的最新版是coreseek4.1版本,2011年发布的,是基于Sphinx2.0.2的,早先有一个版本coreseek3.2.14版,2010年发布的,此中的Sphinx是0.9.9版。看版本号也能看到两者厘革很大,2.0.2版性能更好。以是发起利用coreseek4.1版。
自测安装脚本如下:- #下载coreseek4.1版
- wget http://files.opstool.com/man/coreseek-4.1-beta.tar.gz
- tar zxvf coreseek-4.1-beta.tar.gz
- cd coreseek-4.1-beta
- cat README.txt #readme写得很详细,
- #安装中文分词
- cd mmseg-3.2.14
- ./bootstrap
- ./configure --prefix=/opt/modules/mmseg3
- make && make install
- #安装coreseek
- cd csft-4.1/
- ./buildconf.sh
- ./configure --prefix=/opt/modules/coreseek4.1 --without-unixodbc --with-mmseg --with-mmseg-includes=/opt/modules/mmseg3/include/mmseg/ --with-mmseg-libs=/opt/modules/mmseg3/lib/ --with-mysql
- make
- make install
复制代码 猛烈发起肯定要好悦目看README文件和内里的测试用例,作者还好坏常费心的。非常完满,如今coreseek的官方网站因存案题目打不开。- 目录说明:
- csft-x.y.z:coreseek源代码
- mmseg-i.j.k:mmseg源代码
- testpack:测试配置和数据包
- testpack测试说明:
- 目录说明:
- api:api接口和测试脚本
- etc:配置文件
- etc/pysource:python数据源脚本
- var:运行数据
- var/data:索引文件
- var/log:搜索日志
 - var/test:测试源数据
- 配置1:
- 测试对象:xml数据源,中文分词与搜索
- 对应配置:etc/csft.conf
- 测试数据:var/test/test.xml
- PHP程序:api/test_coreseek.php
- 配置2:
- 测试对象:xml数据源,单字切分与搜索
- 对应配置:etc/csft_cjk.conf
- 测试数据:var/test/test.xml
- PHP程序:api/test_coreseek.php
- 配置3:
- 测试对象:mysql数据源,中文分词与搜索
- 对应配置:etc/csft_mysql.conf
- 测试数据:var/test/documents.sql
- PHP程序:api/test_coreseek.php
- 测试说明:请先将测试数据导入数据库,并设置好配置文件中的MySQL用户密码数据库
- 配置4:
- 测试对象:python数据源,中文分词与搜索
- 对应配置:etc/csft_demo_python.conf
- 数据脚本:etc/pysource/csft_demo/__init__.py
- PHP程序:api/test_coreseek.php
- 测试说明:请先安装Python 2.6 (x86)
- 配置5:
- 测试对象:python+mssql数据源,中文分词与搜索
- 对应配置:etc/csft_demo_python_pymssql.conf
- 数据脚本:etc/pysource/csft_demo_pymssql/__init__.py
- PHP程序:api/test_coreseek.php
- 测试说明:请先安装Python 2.6 (x86)、pymssql(py2.6)
- coreseek-4.y.z测试:
- 配置6:
- 测试对象:RT实时索引,中文分词与搜索
- 对应配置:etc/csft_rtindex.conf
- PHP程序:api/test_coreseek_rtindex.php
- 配置7:
- 测试对象:RT实时索引,单字切分与搜索
- 对应配置:etc/csft_rtindex_cjk.conf
- PHP程序:api/test_coreseek_rtindex.php
复制代码 二、sphinx常见报错及办理办法
第一个报错:WARNING: key 'sql_query' is not multi-value; value in E:/Lnmp/Bin/Sphinx/sphinx.
- using config file 'E:/Lnmp/Bin/Sphinx/sphinx.conf'...
- WARNING: key 'sql_query_info' was permanently removed from Sphinx configuration.
- Refer to documentation for details.
- indexing index 'test1'...
复制代码 报错提示:设置项sql_query_info已经被设置文件中永世移除,这是Sphinx 2.2.10-id64-release (2c212e0)版本的一些修改,别的被移除的设置项另有charset_type设置。
第二个报错:FATAL: failed to lock E:/Lnmp/Cache/Sphinx/test.spl: No error, will not index. T
- using config file 'E:/Lnmp/Bin/Sphinx/sphinx.conf'...
- indexing index 'test1'...
- FATAL: failed to lock E:/Lnmp/Cache/Sphinx/test.spl: No error, will not index. Try --rotate option.
复制代码 报错提示:无法锁定文件test.spl,这是由于建索引时,则须要锁定索引spl文件,而假如正在提供搜刮服务,则这个文件无法锁定。以是报此错,精确的办理办法是在建索引下令后加参数:--rotate 可以在不绝searchd的环境下索引。
--rotate send SIGHUP to searchd when indexing is over to rotate updated indexes automatically。
第三个报错:WARNING: attribute 'id' not found - IGNORING
- using config file 'E:/Lnmp/Bin/Sphinx/sphinx.conf'...
- indexing index 'test1'...
- WARNING: attribute 'id' not found - IGNORING
- total 0 docs, 0 bytes
- total 0.051 sec, 0 bytes/sec, 0.00 docs/sec
- 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
复制代码 报错提示:属性id未找到,由于我的SQL是sql_query=select id,title from webinfo,id是表的主键。而在索引设置中又有sql_attr_uint = id ,而sphinx是不能利用主键来做属性字段,办理方法:可以去掉sql_attr_uint = id 这行设置,大概把SQL改成:
sql_query = SELECT id,id as ids,.. from 表,然后设置里再利用:sql_attr_uint = ids
第四个报错:ERROR: index 'test1': No fields in schema - will not index.
- using config file 'E:/Lnmp/Bin/Sphinx/sphinx.conf'...
- indexing index 'test1'...
- ERROR: index 'test1': No fields in schema - will not index.
- total 0 docs, 0 bytes
- total 0.019 sec, 0 bytes/sec, 0.00 docs/sec
- 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
复制代码 报错提示:在模式中没有字段,不会索引。简单明确一下,由于我的SQL是:sql_query=select id,id as ids,title, from webinfo,而id和title都当做属性被索引,sphinx搜刮是想通过索引项,然后查询出别的的非索引 项,即id和title都被索引了,通过id,title搜刮出来的效果里有什么呢?就是没有别的的字段可供搜刮出来,索引也没什么意义。以是须要更改sql,增长查询的字段,改成如下即可。
sql_query=select id,id as ids,title,url,keywords,description from webinfo
sphinx在利用时遇见的错误肯定不但这几个,这里只是列了一些我碰到的并通过办理方法办理了的报错。
末了备注:Sphinx是我在2017-2019年期间重要利用的搜刮引擎服务,厥后没用过。改用ES了。
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!qidao123.com:ToB企服之家,中国第一个企服评测及软件市场,开放入驻,技术点评得现金 |