Expert: returns a readonly reader, covering all committed as well as un-committed changes to the index. This provides "near real-time" searching, in that changes made during an IndexWriter session can be quickly made available for searching without closing the writer nor calling {@link #commit}.

Note that this is functionally equivalent to calling {#commit} and then using {@link IndexReader#open} to open a new reader. But the turarnound time of this method should be faster since it avoids the potentially costly {@link #commit}.

You must close the {@link IndexReader} returned by this method once you are done using it.

It's near real-time because there is no hard guarantee on how quickly you can get a new reader after making changes with IndexWriter. You'll have to experiment in your situation to determine if it's faster enough. As this is a new and experimental feature, please report back on your findings so we can learn, improve and iterate.

The resulting reader suppports {@link IndexReader#reopen}, but that call will simply forward back to this method (though this may change in the future).

The very first time this method is called, this writer instance will make every effort to pool the readers that it opens for doing merges, applying deletes, etc. This means additional resources (RAM, file descriptors, CPU time) will be consumed.

For lower latency on reopening a reader, you should call {@link #setMergedSegmentWarmer} to call {@link #setMergedSegmentWarmer} to pre-warm a newly merged segment before it's committed to the index. This is important for minimizing index-to-search delay after a large merge.

If an addIndexes* call is running in another thread, then this reader will only search those segments from the foreign index that have been successfully copied over, so far

.

NOTE: Once the writer is closed, any outstanding readers may continue to be used. However, if you attempt to reopen any of those readers, you'll hit an {@link AlreadyClosedException}.

NOTE: This API is experimental and might change in incompatible ways in the next release.

Namespace: Lucene.Net.Index
Assembly: Lucene.Net (in Lucene.Net.dll) Version: 2.9.4.1

Syntax

C#
public virtual IndexReader GetReader()
Visual Basic
Public Overridable Function GetReader As IndexReader
Visual C++
public:
virtual IndexReader^ GetReader()

Return Value

IndexReader that covers entire index plus all changes made so far by this IndexWriter instance

See Also