Method GetReader
GetReader(Boolean)
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 Commit().
Note that this is functionally equivalent to calling Flush() and then opening a new reader. But the turnaround time of this method should be faster since it avoids the potentially costly Commit().
You must close the 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 fast 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 supports DoOpenIfChanged(), 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 set MergedSegmentWarmer 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 disposed, any
outstanding readers may continue to be used. However,
if you attempt to reopen any of those readers, you'll
hit an
@lucene.experimental
Declaration
public virtual DirectoryReader GetReader(bool applyAllDeletes)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | applyAllDeletes |
Returns
Type | Description |
---|---|
DirectoryReader | IndexReader that covers entire index plus all changes made so far by this IndexWriter instance |