You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Jordon Saardchit <jo...@erent.com> on 2011/12/02 23:03:48 UTC

IndexReader.openIfChanged Doesn't Work on MultiReader

Just checking if this is a known issue or if I should report it.

I have a MultiReader made up of 3 different indexes.  If changes are made to either of the 3 underlying indexes, isCurrent() returns false (correctly) on said MultiReader.  However, if I use the method IndexReader.openIfChanged() on the MultiReader, a new MultiReader is returned (it does NOT return null), but its isCurrent() method is still reporting false.  Also, a search using this new MultiReader doesn't not see the index changes (deletes and additions).  I have to explicitly close the MultiReader and open it again to see changes, but the documentation states this is an inefficient way of refreshing readers.

I assumed someone must have run into this before?

Jordon


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


RE: IndexReader.openIfChanged Doesn't Work on MultiReader

Posted by Uwe Schindler <uw...@thetaphi.de>.
Hi,

if you used openIfChanged(boolean readOnly), there was a bug, see
https://issues.apache.org/jira/browse/LUCENE-3630

The problem is that MultiReader should throw UOE on openIfChanged(false), as
it does not support reopen in read-write mode. For reopening with
openIfChanged(true) it should simply delegate to openIfChanged(), but a
method signature clash was causing it to do cloning of the MultiReader if
the readOnly parameter was true - leading to the behavior you have seen.

A quick fix on your side should be *not* to use openIfChanged(IR, true) but
instead openIfChanged(IR) without a boolean parameter (which defaults to
read-only mode). Reopening in R/W mode is not supported at all.

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: Uwe Schindler [mailto:uwe@thetaphi.de]
> Sent: Saturday, December 03, 2011 12:33 AM
> To: java-user@lucene.apache.org
> Subject: RE: IndexReader.openIfChanged Doesn't Work on MultiReader
> 
> Hi,
> 
> > I have a MultiReader made up of 3 different indexes.  If changes are
> > made
> to
> > either of the 3 underlying indexes, isCurrent() returns false
> > (correctly)
> on said
> > MultiReader.  However, if I use the method IndexReader.openIfChanged()
> > on the MultiReader, a new MultiReader is returned (it does NOT return
> > null),
> but
> > its isCurrent() method is still reporting false.  Also, a search using
> this new
> > MultiReader doesn't not see the index changes (deletes and additions).
> > I
> have
> > to explicitly close the MultiReader and open it again to see changes,
> > but
> the
> > documentation states this is an inefficient way of refreshing readers.
> 
> It is not inefficient as MultiReader is just a light wrapper around a
collection of
> readers. If you simply openIfChanged (!) each subreader yourself and wrap
> them by a new MultiReader it will not slowdown anything.
> MultiReader.doOpenIfChanged does nothing else, but maybe with a bug
> introduced by the refactoring.
> 
> > I assumed someone must have run into this before?
> 
> Can you open an issue at https://issues.apache.org/jira/browse/LUCENE ?
> 
> Uwe
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org


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


RE: IndexReader.openIfChanged Doesn't Work on MultiReader

Posted by Uwe Schindler <uw...@thetaphi.de>.
Hi,

> I have a MultiReader made up of 3 different indexes.  If changes are made
to
> either of the 3 underlying indexes, isCurrent() returns false (correctly)
on said
> MultiReader.  However, if I use the method IndexReader.openIfChanged() on
> the MultiReader, a new MultiReader is returned (it does NOT return null),
but
> its isCurrent() method is still reporting false.  Also, a search using
this new
> MultiReader doesn't not see the index changes (deletes and additions).  I
have
> to explicitly close the MultiReader and open it again to see changes, but
the
> documentation states this is an inefficient way of refreshing readers.

It is not inefficient as MultiReader is just a light wrapper around a
collection of readers. If you simply openIfChanged (!) each subreader
yourself and wrap them by a new MultiReader it will not slowdown anything.
MultiReader.doOpenIfChanged does nothing else, but maybe with a bug
introduced by the refactoring.

> I assumed someone must have run into this before?

Can you open an issue at https://issues.apache.org/jira/browse/LUCENE ?

Uwe


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