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

[复制链接]
发表于 2026-2-12 02:44:35 | 显示全部楼层 |阅读模式
一、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版。
    自测安装脚本如下:
  1. #下载coreseek4.1版
  2. wget http://files.opstool.com/man/coreseek-4.1-beta.tar.gz
  3. tar zxvf coreseek-4.1-beta.tar.gz
  4. cd coreseek-4.1-beta
  5. cat README.txt #readme写得很详细,
  6. #安装中文分词
  7. cd mmseg-3.2.14
  8. ./bootstrap
  9. ./configure --prefix=/opt/modules/mmseg3
  10. make && make install
  11. #安装coreseek
  12. cd csft-4.1/
  13. ./buildconf.sh
  14. ./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
  15. make
  16. make install
复制代码
     猛烈发起肯定要好悦目看README文件和内里的测试用例,作者还好坏常费心的。非常完满,如今coreseek的官方网站因存案题目打不开。
  1. 目录说明:
  2. csft-x.y.z:coreseek源代码
  3. mmseg-i.j.k:mmseg源代码
  4. testpack:测试配置和数据包
  5. testpack测试说明:
  6. 目录说明:
  7. api:api接口和测试脚本
  8. etc:配置文件
  9. etc/pysource:python数据源脚本
  10. var:运行数据
  11. var/data:索引文件
  12. var/log:搜索日志日志
  13. var/test:测试源数据
  14. 配置1:
  15.         测试对象:xml数据源,中文分词与搜索
  16.         对应配置:etc/csft.conf
  17.         测试数据:var/test/test.xml
  18.         PHP程序:api/test_coreseek.php
  19. 配置2:
  20.         测试对象:xml数据源,单字切分与搜索
  21.         对应配置:etc/csft_cjk.conf
  22.         测试数据:var/test/test.xml
  23.         PHP程序:api/test_coreseek.php
  24. 配置3:
  25.         测试对象:mysql数据源,中文分词与搜索
  26.         对应配置:etc/csft_mysql.conf
  27.         测试数据:var/test/documents.sql
  28.         PHP程序:api/test_coreseek.php
  29.         测试说明:请先将测试数据导入数据库,并设置好配置文件中的MySQL用户密码数据库
  30. 配置4:
  31.         测试对象:python数据源,中文分词与搜索
  32.         对应配置:etc/csft_demo_python.conf
  33.         数据脚本:etc/pysource/csft_demo/__init__.py
  34.         PHP程序:api/test_coreseek.php
  35.         测试说明:请先安装Python 2.6 (x86)
  36. 配置5:
  37.         测试对象:python+mssql数据源,中文分词与搜索
  38.         对应配置:etc/csft_demo_python_pymssql.conf
  39.         数据脚本:etc/pysource/csft_demo_pymssql/__init__.py
  40.         PHP程序:api/test_coreseek.php
  41.         测试说明:请先安装Python 2.6 (x86)、pymssql(py2.6)
  42. coreseek-4.y.z测试:
  43. 配置6:
  44.     测试对象:RT实时索引,中文分词与搜索
  45.     对应配置:etc/csft_rtindex.conf
  46.     PHP程序:api/test_coreseek_rtindex.php
  47. 配置7:
  48.     测试对象:RT实时索引,单字切分与搜索
  49.     对应配置:etc/csft_rtindex_cjk.conf
  50.     PHP程序:api/test_coreseek_rtindex.php
复制代码
二、sphinx常见报错及办理办法

第一个报错:WARNING: key 'sql_query' is not multi-value; value in E:/Lnmp/Bin/Sphinx/sphinx.
  1. using config file 'E:/Lnmp/Bin/Sphinx/sphinx.conf'...
  2. WARNING: key 'sql_query_info' was permanently removed from Sphinx configuration.
  3. Refer to documentation for details.
  4. 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
  1. using config file 'E:/Lnmp/Bin/Sphinx/sphinx.conf'...
  2. indexing index 'test1'...
  3. 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
  1. using config file 'E:/Lnmp/Bin/Sphinx/sphinx.conf'...
  2. indexing index 'test1'...
  3. WARNING: attribute 'id' not found - IGNORING
  4. total 0 docs, 0 bytes
  5. total 0.051 sec, 0 bytes/sec, 0.00 docs/sec
  6. total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
  7. 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.
  1. using config file 'E:/Lnmp/Bin/Sphinx/sphinx.conf'...
  2. indexing index 'test1'...
  3. ERROR: index 'test1': No fields in schema - will not index.
  4. total 0 docs, 0 bytes
  5. total 0.019 sec, 0 bytes/sec, 0.00 docs/sec
  6. total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
  7. 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企服之家,中国第一个企服评测及软件市场,开放入驻,技术点评得现金

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表