Mox Shah
Mox Shah

Reputation: 3015

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?

Upvotes: 3

Views: 4766

Answers (1)

Mox Shah
Mox Shah

Reputation: 3015

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.

Upvotes: 2

Related Questions