Search code examples
c#lucenelucene.net

Error "No segments* file found" while trying to search a Lucene directory


I am trying to integrate Lucene.Net in a web app. So I downloaded the sample project from this CodeProject article.

But when I try it I keep getting this message in the Search method

No segments* file found in
[My Directory]\Lucene.Net-search-MVC-sample-site-master\LuceneSearch.Mvc\lucene_index
lockFactory=Lucene.Net.Store.NativeFSLockFactory: files:

The error occurs in this line

using (var searcher = new IndexSearcher(_directory, false))

Did anyone face this error ?


Solution

  • The Lucene need to create indexes before it can search. It looks like index files are missing in the directory specified.

    Did you click Create Index button in UI? If so what happens, it is supposed to create "lucene_index" directory under MVC site, if it didn't, make sure to give account running website read/write access to that directory.