lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nick Bailey" <>
Subject Re: IndexReader.isCurrent for cached indexes
Date Thu, 10 Sep 2009 14:53:30 GMT
Our commit code will close the IndexWriter after adding the documents and before we see the
log message indicating the documents have been added and deleted, so I don't believe that
is the problem.

Thanks for the tip about reopen.  I actually noticed that when researching this problem but
didn't think it was related.

We are running 2.4.1

-----Original Message-----
From: "Ian Lea" <>
Sent: Thursday, September 10, 2009 5:05am
Subject: Re: IndexReader.isCurrent for cached indexes

isCurrent() will only return true if there have been committed changes
to the index.  Maybe for some reason your index update job hasn't
committed or closed the index.

Probably not relevant to this problem, but your reopen code snippet
doesn't close the old reader.  It should.  See the javadocs.

What version of lucene are you running?


On Wed, Sep 9, 2009 at 10:33 PM, Nick Bailey
<> wrote:
> Looking for some help figuring out a problem with the IndexReader.isCurrent() method
and cached indexes.
> We have a number of lucene indexes that we attempt to keep in memory after an initial
query is performed.  In order to prevent the indexes from becoming stale, we check for changes
about every minute by calling isCurrent().  If the index has changed, we will then reopen
> From our logs it appears that in some cases isCurrent() will return true even though
the index has changed since the last time the reader was opened.
> The code to refresh the index is basically this:
> // Checked every minute
> if(!reader.isCurrent()){
>   // reopen the existing reader
>   reader = this.searcher.getIndexReader();
>   reader = reader.reopen();
> }
> This is an example of the problem from the logs:
> 2009-08-29 17:50:51,387 Indexed 0 documents and deleted 1 documents from index 'example'
in 0 ms
> 2009-08-30 03:11:58,410 Indexed 0 documents and deleted 5 documents from index 'example'
in 0 ms
> 2009-08-30 16:30:03,466 Using cached reader <age=88648201 lastRefresh=81415526>
> // numbers indicate milliseconds since opened or refreshed aka age = 24.6hrs, lastRefresh
= 22.6hrs
> The logs indicate we deleted documents from the index at about 5:50 on August 29th, and
then again on the 30th at 3:11.  Then at 4:30 on we attempted to query the index.  We found
the cached reader and used it, however, the last time the cache was refreshed was about 22
hours previously, coinciding with the first delete.  The index should have been reopened
after the second delete.
> I have checked, and the code to refresh the indexes is definitely being run every 60
seconds.  All I can see is that the problem might be with the isCurrent() method.
> Could it be due to holding the reader open for so long? Any other ideas?
> Thanks a lot,
> Nick Bailey
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message