【发布时间】:2014-03-24 15:49:52
【问题描述】:
我认为,我的 Lucene 索引(使用 Lucene4.1 使用 Solr 构建)已损坏。在尝试使用以下代码读取索引时,我得到 org.apache.solr.common.SolrException: No such core: collection1 异常:
File configFile = new File(cacheFolder + File.separator + "solr.xml");
CoreContainer container = new CoreContainer(cacheFolder, configFile);
SolrServer server = new EmbeddedSolrServer(container, "collection1");
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("q", idFieldName + ":" + ClientUtils.escapeQueryChars(queryId));
params.set("fl",idFieldName+","+valueFieldName);
QueryResponse response = server.query(params)
我使用“checkindex”工具来检查索引的完整性,它似乎无法通过抛出以下错误来执行任务:
Opening index @ /....../solrindex_cache/zookeeper/solr/collection1/data/index
ERROR: could not read any segments file in directory
java.io.FileNotFoundException: /....../solrindex_cache/zookeeper/solr/collection1/data/index/segments_b5tb (No such file or directory)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:233)
at org.apache.lucene.store.MMapDirectory.openInput(MMapDirectory.java:223)
at org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:285)
at org.apache.lucene.index.SegmentInfos$1.doBody(SegmentInfos.java:347)
at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:783)
at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:630)
at org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:343)
at org.apache.lucene.index.CheckIndex.checkIndex(CheckIndex.java:383)
at org.apache.lucene.index.CheckIndex.main(CheckIndex.java:1777)
索引检查器正在寻找的文件segments_b5tb 确实在索引文件夹中丢失。唯一看起来相似的文件是segments.gen。
有什么方法可以诊断出了什么问题,如果可能的话,一定要修复它,因为我花了 2 周时间来建立这个索引...
非常感谢您的善意建议!
【问题讨论】:
-
添加:通过弄乱它,我认为它只会变得更糟:由于索引可能已损坏,当我再次对其进行测试时,它似乎重新创建了“segment.gen”文件,并且重新创建这些段文件(即 si、tip、doc、fdx 等文件)。然后我立即退出程序,以避免所有分段文件丢失。但现在似乎索引与那些段文件完全分离,即使物理上在那里。我想这更复杂,但是有什么办法可以解决这个问题吗?
-
您是否尝试运行 CheckIndex 的fixIndex 方法?