Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
修复lucene 4.1/solr损坏索引_Solr_Lucene - Fatal编程技术网

修复lucene 4.1/solr损坏索引

修复lucene 4.1/solr损坏索引,solr,lucene,Solr,Lucene,我的Lucene索引——使用Lucene4.1用Solr构建——我认为已经损坏了。尝试使用以下代码读取索引时,我得到org.apache.solr.common.SolrException:没有这样的核心:collection1异常: File configFile = new File(cacheFolder + File.separator + "solr.xml"); CoreContainer container = new CoreContainer(cacheFolder, conf

我的Lucene索引——使用Lucene4.1用Solr构建——我认为已经损坏了。尝试使用以下代码读取索引时,我得到
org.apache.solr.common.SolrException:没有这样的核心: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”util检查索引的完整性,它似乎无法通过抛出以下错误来执行任务:

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)
Opening index@/…../solrindex\u cache/zookeeper/solr/collection1/data/index
错误:无法读取目录中的任何段文件
java.io.FileNotFoundException:/…/solrindex\u cache/zookeeper/solr/collection1/data/index/segments\u b5tb(无此类文件或目录)
位于java.io.RandomAccessFile.open(本机方法)
位于java.io.RandomAccessFile。(RandomAccessFile.java:233)
位于org.apache.lucene.store.MMapDirectory.openInput(MMapDirectory.java:223)
位于org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:285)
位于org.apache.lucene.index.SegmentInfos$1.doBody(SegmentInfos.java:347)
位于org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:783)
在org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:630)上
位于org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:343)
位于org.apache.lucene.index.CheckIndex.CheckIndex(CheckIndex.java:383)
位于org.apache.lucene.index.CheckIndex.main(CheckIndex.java:1777)
索引检查器正在查找的文件
segments\u b5tb
确实在索引文件夹中丢失。唯一看起来相似的文件是
segments.gen

有没有办法诊断出什么地方出了问题,如果可能的话,尽一切办法修复它,因为我花了两周的时间建立这个索引


非常感谢你的忠告

如果segments.gen文件是您看到的唯一文件,则可能是运气不好,否则,您可以尝试使用检查错误并修复索引。由于该工具通过删除有问题的段来修复索引,因此可能会导致某些数据丢失。

ADD:如果弄乱它,我认为情况会变得更糟:由于索引可能已损坏,当我再次测试它时,它似乎已重新创建了“segment.gen”文件,并重新创建了这些段文件(即si、tip、doc、fdx等文件)。然后我立即退出程序,以避免所有分段文件丢失。但现在似乎索引已与这些分段文件完全分离,即使它们在物理上存在。我想这更复杂,但是否有任何方法可以解决此问题?是否尝试运行CheckIndex方法?谢谢。没有,有分段文件nts.gen和许多其他“si、tip、doc、fdx”文件。但CheckIndex抱怨的文件丢失,即“segments_b5tb”,因此,CheckIndex无法继续,只能抛出上述错误消息并退出。