lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: IndexReader.reopen issue
Date Mon, 23 Jun 2008 14:28:22 GMT

My guess is your newIndexReader is in fact the same as your  
previousIndexReader, in which case getting the same gen in your  
LOG.info is expected.

It seems like what you want is a way to force a new reader to be  
returned by reopen() even if there were no changes to the index.  Ie,  
you need to forcefully get a new reader which you can make changes to,  
such that it does not affect the original reader.  Maybe we need a  
reopen(boolean forced)?

Alternatively, we could implement IndexReader.clone() for this  
situation.  Then one could first clone() an IndexReader, do a reopen()  
on the clone if others may have changed the index, then make changes  
through the new reader.

Mike

Jason Rutherglen wrote:

> When this code is run, why are the generation numbers the same?  The  
> desired behavior is that the delete happens only to the  
> newIndexReader, leaving the previousIndexReader unaffected.
>
> IndexReader previousIndexReader =  
> latestIndexSnapshot.getIndexReader();
> IndexReader newIndexReader = previousIndexReader.reopen(); //  
> returns the same reader?
> newIndexReader.deleteDocument(10);
> newIndexReader.flush();
> newIndexReader = newIndexReader.reopen();
> LOG.info("previous reader gen:  
> "+previousIndexReader.getIndexCommit().getGeneration()+"  
> newIndexReader gen:  
> "+newIndexReader.getIndexCommit().getGeneration());
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message