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 it.

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: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to