如何修复损坏的lucene索引? [英] How to repair corrupted lucene index?
问题描述
我的服务器断电,Lucene索引损坏.我运行了IndexChecker,但失败了:
My server was power loss and lucene index was corrupted. I runned IndexChecker but it fail:
java -cp /home/dthoai/programs/paesia/checker/lucene-core-3.5.0.jar -ea:org.apache.lucene... org.apache.lucene.index.CheckIndex /mnt/peda/paesia/index -fix
Opening index @ /mnt/peda/paesia/index
ERROR: could not read any segments file in directory
java.io.IOException: read past EOF: MMapIndexInput(path="/mnt/peda/paesia/index/segments_ls0l")
at org.apache.lucene.store.MMapDirectory$MMapIndexInput.readByte(MMapDirectory.java:279)
at org.apache.lucene.store.ChecksumIndexInput.readByte(ChecksumIndexInput.java:41)
at org.apache.lucene.store.DataInput.readInt(DataInput.java:84)
at org.apache.lucene.store.DataInput.readLong(DataInput.java:126)
at org.apache.lucene.index.SegmentInfo.<init>(SegmentInfo.java:202)
at org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:286)
at org.apache.lucene.index.SegmentInfos$1.doBody(SegmentInfos.java:363)
at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:754)
at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:593)
at org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:359)
at org.apache.lucene.index.CheckIndex.checkIndex(CheckIndex.java:327)
at org.apache.lucene.index.CheckIndex.main(CheckIndex.java:1007)
我该如何修复我的Lucene指数?
How can I repair my lucene index?
推荐答案
It looks like the main directory file, segments_N is corrupted. This probably means that the power loss happened while a commit was running.
如果是这种情况,则意味着目录中存在较旧的segments_N文件,并且所引用的段仍然存在并且有效.如果有这样的文件,请尝试删除损坏的 segments_ls0l
文件,然后查看:
If this is the case, this means that there is some chance that an older segments_N file is present in your directory, and that the referenced segments are still present and valid. If there is such a file, try to remove your corrupted segments_ls0l
file and see:
- Lucene是否设法打开索引,
- 您缺少什么数据.
否则,Lucene用户的邮件列表中有一些线程正在讨论重新生成segments_N文件.
Otherwise, there are some threads one Lucene user mailing-list talking about regenerating the segments_N file.
- http://www.gossamer-threads.com/lists/lucene/java-user/102493
- http://www.gossamer-threads.com/lists/lucene/java-user/39744
在执行任何修改之前,请确保备份目录.
Make sure to backup your directory before performing any modification.
这篇关于如何修复损坏的lucene索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!