Yes. New additions to an index are NOT searchable until the indexSearcher/IndexReader is closed and reopened, just as you are observing. I think of it as the IndexSearcher taking a "snapshot" of the index when it is instantiated and operating on that snapshot exclusively thereafter, regardless of what changes are made to the underlying index.
You got it right in one <G>. Best Erick On 9/27/06, Luis Rodrigo Aguado <[EMAIL PROTECTED]> wrote:
Hi all, I have a problem with a lucene-based application I am trying to build. The application is mainly search oriented, and the core of the index is built in a batch process before starting the system. In the application initialization an IndexSearcher object is built, to perform all the searches. However, in some special conditions, an addition to the index may be necessary. In these situations, I build an IndexWriter, add the new document and finish with a writer.optimize() and a writer.close(). After an addition, the index returns perfectly the ideas before the addition, but not the ones that where added when the application was running. Should I renew the IndexSearcher after the additions to be able to return the new Documents? Thanks in advance!