Centos下基于sphinx的开源搜索引擎coreseek的安装 及 sphinx常见报错及解决办法

avatar
作者
猴君
阅读量:0

一、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了。

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!