Class SurrogateDirectoryReader
DirectoryReader is an implementation of CompositeReader that can read indexes in a Directory.
DirectoryReader instances are usually constructed with a call to
one of the static Open()
methods, e.g. Open(Directory).
For efficiency, in this API documents are often referred to via document numbers, non-negative integers which each name a unique document in the index. These document numbers are ephemeral -- they may change as documents are added to and deleted from an index. Clients should thus not rely on a given document having the same number between sessions.
NOTE: IndexReader instances are completely thread safe, meaning multiple threads can call any of its methods, concurrently. If your application requires external synchronization, you should not synchronize on the IndexReader instance; use your own (non-Lucene) objects instead.
Inheritance
Assembly: Lucene.Net.dll
Syntax
[Serializable]
public class SurrogateDirectoryReader : ServerSurrogateObject, IIdentifiableSurrogate
Constructors
Name | Description |
---|---|
SurrogateDirectoryReader(String, DirectoryReader) | Expert: Constructs a DirectoryReader on the given |
Fields
Name | Description |
---|---|
DEFAULT_TERMS_INDEX_DIVISOR | Default termInfosIndexDivisor. |
m_directory | The index directory. |
Properties
Name | Description |
---|---|
Directory | Returns the directory this index resides in. |
WrappedInstance |
Methods
Name | Description |
---|---|
GetSurrogateId() | |
GetSurrogateObjectState() | |
IndexExists(Directory) | Returns |
InvokeMethod(String, Int32, Object[], ModuleOperationContext) | |
InvokePropertyGetter(String) | Implement this method to support OpenIfChanged(DirectoryReader).
If this reader does not support reopen, return |
InvokePropertySetter(String, Object) | |
ListCommits(Directory) | Returns all commit points that exist in the Directory. Normally, because the default is KeepOnlyLastCommitDeletionPolicy, there would be only one commit point. But if you're using a custom IndexDeletionPolicy then there could be many commits. Once you have a given commit, you can open a reader on it by calling Open(IndexCommit) There must be at least one commit in the Directory, else this method throws IndexNotFoundException. Note that if a commit is in progress while this method is running, that commit may or may not be returned. |
Open(IndexCommit) | Expert: returns an IndexReader reading the index in the given IndexCommit. |
Open(IndexCommit, Int32) | Expert: returns an IndexReader reading the index in the given
IndexCommit and |
Open(IndexWriter, Boolean) | Open a near real time IndexReader from the IndexWriter. @lucene.experimental |
Open(Directory) | Returns a IndexReader reading the index in the given Directory |
Open(Directory, Int32) | Expert: Returns a IndexReader reading the index in the given Directory with the given termInfosIndexDivisor. |
OpenIfChanged(DirectoryReader) | If the index has changed since the provided reader was
opened, open and return a new reader; else, return
This method is typically far less costly than opening a fully new DirectoryReader as it shares resources (for example sub-readers) with the provided DirectoryReader, when possible. The provided reader is not disposed (you are responsible for doing so); if a new reader is returned you also must eventually dispose it. Be sure to never dispose a reader while other threads are still using it; see SearcherManager to simplify managing this. |
OpenIfChanged(DirectoryReader, IndexCommit) | If the IndexCommit differs from what the
provided reader is searching, open and return a new
reader; else, return |
OpenIfChanged(DirectoryReader, IndexWriter, Boolean) | Expert: If there changes (committed or not) in the
IndexWriter versus what the provided reader is
searching, then open and return a new
IndexReader searching both committed and uncommitted
changes from the writer; else, return 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(). 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 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 MergedSegmentWarmer (on IndexWriterConfig) 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 System.ObjectDisposedException. @lucene.experimental |