lucenenet-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Resnick <jresn...@gmail.com>
Subject IndexReader.Reopen() always returns a new reader, when originally created from IndexWriter.GetReader()
Date Thu, 25 Sep 2014 17:39:05 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message