如何从Solr中恢复删除的索引文件?

问题描述:

当我在磁盘上删除solr的索引文件(在 / solr / data / index solr / data / spellchecker ),当我尝试向它发出请求时,solr会抛出异常:

When I delete solr's index files on disk, (found in /solr/data/index and solr/data/spellchecker), solr throws an exception whenever I try to make a request to it:


java.lang.RuntimeException:java.io .FileNotFoundException:在org.apache.lucene.store.NIOFSDirectory@/.../solr/data/index中找不到段*文件:

java.lang.RuntimeException: java.io.FileNotFoundException: no segments* file found in org.apache.lucene.store.NIOFSDirectory@/…/solr/data/index:

我发现从这里恢复的唯一方法是将数据目录与其他地方的索引文件种子。似乎并不重要。一旦我这样做,我可以运行一个查询来重新加载模式并重新生成索引。这是应该如何工作吗?似乎应该有一种方法来告诉solr从头重新生成这些文件。也许我只是误认为这些文件不是应用程序本身的一部分(由数据这个名字所暗示的)?

The only way I've found to recover from this is to "seed" the data directory with the index files from elsewhere. It doesn't really matter where it seems. Once I do this, I can run a query to reload the schema and regenerate the index. Is this how this is supposed to work? It seems like there should be a way to tell solr to regenerate those files from scratch. Maybe I'm just mistaken in my assumption that these files are not part of the application itself (kind of implied by the name "data")?

如果索引目录存在但是为空,Solr将在启动时抛出该异常。但是,如果您删除该目录,Solr将在启动时创建它并创建空段文件。

Solr will throw that exception at startup if the index directory exists but is empty. However if you delete the directory, Solr will create it and the empty segments files at startup.