As far as I know, you have to open a new instance. I don't think
this is solved in Lucene 2.1 at all.

I do remember discussions a while ago where the general idea
was to open a new reader and, perhaps, fire a few "primer" queries
at it on some background thread. Then, your main thread can switch
to the new one. Of course, you have to do some fancy-dancing to
coordinate all of the threads using that searcher...

Solr has been mentioned as having solved this problem. But I
haven't looked at it myself.

WARNING: Our applications haven't had to worry about this, so
I'm not speaking from actual experience.

Erick


On 5/11/07, Andreas Guther <[EMAIL PROTECTED]> wrote:

Maybe I should add that I am currently using Lucene 2.0.  From other
threads I get the impression that this might be solved in Lucene 2.1.

-----Original Message-----
From: Andreas Guther [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 10, 2007 10:33 PM
To: java-user@lucene.apache.org
Subject: How to re-open the IndexSearcher's IndexReader


Hi,

How can I re-use an IndexSearcher and keep track of changes to the
index?


I am dealing with Index Directories of several GB.  Opening and
IndexSearcher is very expensive and can take several seconds.  Therefore
I am caching the IndexSearcher for re-use.

Our indexes are frequently updated.  Before I pass the IndexSearcher
retrieved from the cache I use the IndexSearcher getIndexReader() method
to get the IndexReader and to check if the IndexReader is current (via
the isCurrent() method).

The isCurrent method is documented as follows:

/**
   * Check whether this IndexReader still works on a current version of
the index.
   * If this is not the case you will need to re-open the IndexReader to
   * make sure you see the latest changes made to the index.
   *
   * @throws IOException
   */

Opening a new  IndexReader  is trivial.  But then how do I set the
IndexSearcher's reader to the new one without getting a new instance?


Thanks in advance for any help.


Andreas





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to