简体   繁体   中英

no segments* file found in Lucene.Net.Store.SimpleFSDirectory@

I've downloaded some samples of Lucene.Net library and tried to run but it always throw this error

no segments* file found in Lucene.Net.Store.SimpleFSDirectory@

It throws an error while creating object at this line,

var searcher = new IndexSearcher(_directory, false)

Is anyone has idea on this? Is there any configuration required to implement this lucene.Net library?

For me it was two issue, 1st this is index was not created so for the 1st time it was throwing this error, Following code resolved that issue.

if (!System.IO.Directory.EnumerateFiles(indexDirectory).Any()) 
{
     return new List<Model>();
}

2nd thing,

Do not forget to dispose object of IndexSearcher , IndexReader and IndexWriter .

Disposing memory of these object in sequence, resolved my issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM