no segments* file found
I need to access a lucene index ( created by crawling several webpages using Nutch) but it is giving the error shown above :
java.io.FileNotFoundException: no segments* file found in org.apache.lucene.store.FSDirectory@/home/<path>: files:
at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:516)
at org.apache.lucene.index.IndexReader.open(IndexReader.java:185)
at org.apache.lucene.index.IndexReader.open(IndexReader.java:148)
at DictionaryGenerator.generateDict(DictionaryGenerator.java:24)
开发者_运维问答 at DictionaryGenerator.main(DictionaryGenerator.java:56)
I googled but the reasons given were not matching the requirements. The fact that files are being shown ( the path) probably means that the directory is not empty.
ThanksAnother hint, as I was having the same error and found that after creating indexes I did not close IndexWriter and it proved very unforgiven. In my indexdirectory I have some .lock files and no segments or segments.gen files which is what Reader is looking for. See here #3 for details
Basically, the error message says that Lucene did not find the proper files in the index directory. I suggest checking the following:
- Verify the path of the index directory fits what you think it should be.
- Do the Nutch and Lucene versions used match? This may stem from a version difference.
- Is there a permissions issue? Can you read the files in the directory?
- Try looking at the index using Luke. If you cannot, there is probably some corruption in the index.
If all these do not help, Please post the indexing part of the code.
Stumbled upon this issue in 2020:
I had opened the IndexReader using the
org.apache.lucene.index.DirectoryReader#open(org.apache.lucene.store.Directory)
method instead of
org.apache.lucene.index.DirectoryReader#open(org.apache.lucene.index.IndexWriter)
The first one resulted in the error described above, while the latter one worked fine on an empty directory - and seems the way to go here.
精彩评论