tags:

views:

52

answers:

2

When my collection of files is updated then I want to search the newest data...

Like windows Advance search option.

A: 

Yes, you can search and index at the same time. The only thing you need to consider is that when you open your IndexReader, it basically takes a "snapshot" of the index: you need to close and reopen the IndexReader to get any new updates (or call reopen, which can be somewhat faster than closing and reopening).

Dean Harding
can i update documents after the optimize the indexwriter
Deepak
Yes, all optimize does is rearrange the files on disk for faster access. It doesn't change the "logical" layout of your index in any way.
Dean Harding
thanks for sharing
Deepak
+1  A: 

From the Lucene FAQ:

Does Lucene allow searching and indexing simultaneously?

Yes. However, an IndexReader only searches the index as of the "point in time" that it was opened. Any updates to the index, either added or deleted documents, will not be visible until the IndexReader is re-opened. So your application must periodically re-open its IndexReaders to see the latest updates. The IndexReader.isCurrent() method allows you to test whether any updates have occurred to the index since your IndexReader was opened.

Admittedly that's a reference to the Java version, but I'd expect the .NET version to work the same way.

Jon Skeet