The answer to all three of your questions is the same: repeat the use of your readers (and, possibly, your authors). You can use the singleton pattern to do this (i.e. declare the reader / writer public). The Lucene FAQ tells you the same thing: share it with your readers, because the first reaaalllyyyy request is slow. Lucene handles all locks for you, so there is no reason why you should not have a common reader.
Probably the easiest way is to just keep your writer and (using the NRT model ). If you rarely have to write to the index, or if you do not need a huge need for speed, then probably OK to open your writer every time. This is what I do.
Edit: added sample code:
public static IndexWriter writer = new IndexWriter(myDir); public JsonResult SearchForStuff(string query) { IndexReader reader = writer.GetReader(); IndexSearcher search = new IndexSearcher(reader);
Xodarap Aug 17 '10 at 19:39 2010-08-17 19:39
source share