You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by Jonathan Resnick <jr...@gmail.com> on 2014/09/25 19:39:05 UTC
IndexReader.Reopen() always returns a new reader, when originally
created from IndexWriter.GetReader()
The Lucene in Action book contains the following code snippet:
IndexReader newReader = currentSearcher.getIndexReader().reopen();
if (newReader != currentSearcher.getIndexReader()) {
// warm new reader
// ...
}
When I try this out, I find that a new IndexReader is *always* returned,
even when no changes have been committed to the index. Looking at the
Lucene.NET source, I see that when the original reader was obtained from a
writer, no effort is made to determine whether the existing reader can just
be returned, eg.
private IndexReader DoReopenFromWriter(bool openReadOnly,
IndexCommit commit)
{
// ...
// TODO: right now we *always* make a new reader; in
// the future we could have write make some effort to
// detect that no changes have occurred
return writer.GetReader();
}
Is this a case of the Lucene.NET implementation differing from the Java
implementation? Or have I misunderstood something about how this mechanism
is intended to work?
Thanks,
Jon