Sphinx找不到索引文件的解决办法

本文介绍了Sphinx在特定情况下无法找到搜索结果的问题及其解决方法。主要原因是indexer未使用--rotate选项导致索引文件名冲突。文章提供了详细的步骤来解决这一问题,包括停止searchd服务、重建索引文件及使用rotate命令。
部署运行你感兴趣的模型镜像

Sphinx某些时候会找不到搜索结果,使用seach命令进行搜索时发现有如下错误:

index 'xxx': search error: failed to open /data/html/index/xxx.sph: No such file or directory

到该目录下发现出现很多名为xxx.new.sph, xxx.new.spa, xxx.new.spm等文件,

而sphinx配置文件中写的索引路径为/data/html/index/xxx。

可以确定是search寻找的是xxx.sph文件,而indexer或searchd将索引文件命名为xxx.new.sph造成无法检索。

这个问题出现的原因和indexer rotate工作方式有关,具体可以参考http://www.sphinxsearch.com/forum/view.html?id=274。

原因引用如下:

It seems that a) the lock files were lost somehow, and b) you ran indexer without --rotate switch. Normally, searchd would create .spl lock files on startup (and kill them on shutdown), and indexer would then refuse to reindex without --rotate switch. indexers sends SIGHUP to searchd when completed (and it should print that out). searchd then does the following: 1) waits for all children to exit 2) renames current index files to .old 3) renames .new index files to current 4) tries to load current index files 5) if something failed, it rollbacks current files from .old and new to .new In your case I would start with double checking directory access rights, users which both indexer and searchd run under, etc. 解决方式为:

searchd --stop # 先停掉searchd,注意如果采用kill的方式,要保证/var/log/searchd.pid文件的一致性

index --all # 重建所有索引,可以看到xxx.sph文件又回来了

searchd # 启动searchd服务

index --all --rotate # 试试用rotate命令重建索引

您可能感兴趣的与本文相关的镜像

AutoGPT

AutoGPT

AI应用

AutoGPT于2023年3月30日由游戏公司Significant Gravitas Ltd.的创始人Toran Bruce Richards发布,AutoGPT是一个AI agent(智能体),也是开源的应用程序,结合了GPT-4和GPT-3.5技术,给定自然语言的目标,它将尝试通过将其分解成子任务,并在自动循环中使用互联网和其他工具来实现这一目标

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值