Indexing 如何在Lucene索引中重新创建已删除的段文件?

Indexing 如何在Lucene索引中重新创建已删除的段文件?,indexing,lucene,segment,Indexing,Lucene,Segment,我不小心删除了我程序的Lucence索引文件夹。当我运行我的程序时,它显示为 Exception in thread "main" org.apache.lucene.index.IndexNotFoundException: no segments* file found in org.apache.lucene.store.MMapDirectory@M:\fbl\org.fazlan.lucene.ms.demo\src\main\resources\index2 lockFactory=

我不小心删除了我程序的Lucence索引文件夹。当我运行我的程序时,它显示为

Exception in thread "main" org.apache.lucene.index.IndexNotFoundException: no segments* file found in org.apache.lucene.store.MMapDirectory@M:\fbl\org.fazlan.lucene.ms.demo\src\main\resources\index2 lockFactory=org.apache.lucene.store.NativeFSLockFactory@cb17ecc: files: [write.lock, _0.fdt, _0.fdx]
at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:801)
at org.apache.lucene.index.StandardDirectoryReader.open(StandardDirectoryReader.java:52)
at org.apache.lucene.index.DirectoryReader.open(DirectoryReader.java:66)
at org.apache.lucene.index.IndexReader.open(IndexReader.java:291)
at org.fazlan.lucene.demo.Searcher.<init>(Searcher.java:28)
at org.fazlan.lucene.demo.FileIndexApplication.main(FileIndexApplication.java:50)
线程“main”org.apache.lucene.index.IndexNotFoundException中的异常:在org.apache.lucene.store中找不到segments*文件。MMapDirectory@M:\fbl\org.fazlan.lucene.ms.demo\src\main\resources\index2 lockFactory=org.apache.lucene.store。NativeFSLockFactory@cb17ecc:文件:[write.lock、_0.fdt、_0.fdx]
在org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:801)上
位于org.apache.lucene.index.StandardDirectoryReader.open(StandardDirectoryReader.java:52)
位于org.apache.lucene.index.DirectoryReader.open(DirectoryReader.java:66)
位于org.apache.lucene.index.IndexReader.open(IndexReader.java:291)
位于org.fazlan.lucene.demo.Searcher.(Searcher.java:28)
位于org.fazlan.lucene.demo.FileIndexApplication.main(FileIndexApplication.java:50)

我能做什么?我在网上搜遍了,但找不到任何解决办法?有没有办法用删除的段文件重建索引

这应该可以通过创建一个与您现在拥有的段大小相同的索引来实现。然后使用它的段文件作为索引。您需要替换段文件中与实际文件名匹配的文件名