Apache Lucene.Net 2.4.0 Class Library API

IndexReader Members

IndexReader overview

Public Static Methods

GetCurrentVersionOverloaded. Reads version number from segments files. The version number is initialized with a timestamp and then increased by one for each change of the index.
IndexExistsOverloaded. Returns
true
if an index exists at the specified directory. If the directory does not exist or if there is no index in it.
false
is returned.
IsLockedOverloaded. Returns
true
iff the index in the named directory is currently locked.
LastModifiedOverloaded. Returns the time the index in the named directory was last modified. Do not use this to check whether the reader is still up-to-date, use {@link #IsCurrent()} instead.
ListCommits Returns all commit points that exist in the Directory. Normally, because the default is {@link KeepOnlyLastCommitDeletionPolicy}, there would be only one commit point. But if you're using a custom {@link IndexDeletionPolicy} then there could be many commits. Once you have a given commit, you can open a reader on it by calling {@link IndexReader#open(IndexCommit)} There must be at least one commit in the Directory, else this method throws {@link java.io.IOException}. Note that if a commit is in progress while this method is running, that commit may or may not be returned array.
Main Prints the filename and size of each file within a given compound file. Add the -extract flag to extract files to the current working directory. In order to make the extracted version of the index work, you have to copy the segments file from the compound index into the directory where the extracted files are stored.
OpenOverloaded. Returns a read/write IndexReader reading the index in an FSDirectory in the named path. NOTE: Starting in 3.0 this will return a readOnly IndexReader. Throws CorruptIndexException if the index is corrupt. Throws IOException if there is a low-level IO error.
UnlockObsolete.  

Public Instance Methods

Close Closes files associated with this index. Also saves any new deletions to disk. No other methods should be called after this has been called.
Commit Commit changes resulting from delete, undeleteAll, or setNorm operations If an exception is hit, then either no changes or all changes will have been committed to the index (transactional semantics).
DecRef Expert: decreases the refCount of this IndexReader instance. If the refCount drops to 0, then pending changes (if any) are committed to the index and this reader is closed.
DeleteDocumentDeletes the document numbered
docNum
. Once a document is deleted it will not appear in TermDocs or TermPostitions enumerations. Attempts to read its field with the {@link #document} method will result in an error. The presence of this document may still be reflected in the {@link #docFreq} statistic, though this will be corrected eventually as the index is further modified.
DeleteDocumentsDeletes all documents that have a given
term
indexed. This is useful if one uses a document field to hold a unique ID string for the document. Then to delete such a document, one merely constructs a term with the appropriate field and the unique ID string as its text and passes it to this method. See {@link #DeleteDocument(int)} for information about when this deletion will become effective.
Directory Returns the directory associated with this index. The Default implementation returns the directory specified by subclasses when delegating to the IndexReader(Directory) constructor, or throws an UnsupportedOperationException if one was not specified.
DocFreqReturns the number of documents containing the term
t
.
DocumentOverloaded. Returns the stored fields of the
n
th
Document
in this index.
EnsureOpen 
Equals (inherited from Object)Determines whether the specified Object is equal to the current Object.
Flush
GetFieldNames Get a list of unique field names that exist in this index and have the specified field option information.
GetHashCode (inherited from Object)Serves as a hash function for a particular type. GetHashCode is suitable for use in hashing algorithms and data structures like a hash table.
GetIndexCommit Expert: Return the IndexCommit that this reader has open. This method is only implemented by those readers that correspond to a Directory with its own segments_N file. WARNING: This API is new and experimental and may suddenly change.
GetRefCount 
GetTermFreqVectorOverloaded. Return a term frequency vector for the specified document and field. The returned vector contains terms and frequencies for the terms in the specified field of this document, if the field had the storeTermVector flag set. If termvectors had been stored with positions or offsets, a TermPositionsVector is returned.
GetTermFreqVectors Return an array of term frequency vectors for the specified document. The array contains a vector for each vectorized field in the document. Each vector contains terms and frequencies for all terms in a given vectorized field. If no such fields existed, the method returns null. The term vectors that are returned my either be of type TermFreqVector or of type TermPositionsVector if positions or offsets have been stored.
GetTermInfosIndexDivisor 
GetType (inherited from Object)Gets the Type of the current instance.
GetVersion Version number when this IndexReader was opened. Not implemented in the IndexReader base class.
HasDeletionsReturns true if any documents have been deleted
HasNormsReturns true if there are norms stored for this field.
IncRef Expert: increments the refCount of this IndexReader instance. RefCounts are used to determine when a reader can be closed safely, i.e. as soon as there are no more references. Be sure to always call a corresponding {@link #decRef}, in a finally clause; otherwise the reader may never be closed. Note that {@link #close} simply calls decRef(), which means that the IndexReader will not really be closed until {@link #decRef} has been called for all outstanding references.
IsCurrent Check whether this IndexReader is still using the current (i.e., most recently committed) version of the index. If a writer has committed any changes to the index since this reader was opened, this will return
false
, in which case you must open a new IndexReader in order to see the changes. See the description of the
autoCommit
flag which controls when the {@link IndexWriter} actually commits changes to the index. Not implemented in the IndexReader base class.
IsDeletedReturns true if document n has been deleted
IsOptimized Checks is the index is optimized (if it has a single segment and no deletions). Not implemented in the IndexReader base class.
MaxDocReturns one greater than the largest possible document number. This may be used to, e.g., determine how big to allocate an array which will have an element for every document number in an index.
NormsOverloaded. Returns the byte-encoded normalization factor for the named field of every document. This is used by the search code to score documents.
NumDeletedDocs Returns the number of deleted docs.
NumDocsReturns the number of documents in this index.
Reopen 
SetNormOverloaded. Expert: Resets the normalization factor for the named field of the named document. The norm represents the product of the field's {@link Lucene.Net.Documents.Fieldable#SetBoost(float) boost} and its {@link Similarity#LengthNorm(String, int) length normalization}. Thus, to preserve the length normalization values when resetting this, one should base the new value upon the old.
SetTermInfosIndexDivisorFor IndexReader implementations that use TermInfosReader to read terms, this sets the indexDivisor to subsample the number of indexed terms loaded into memory. This has the same effect as {@link IndexWriter#setTermIndexInterval} except that setting must be done at indexing time while this setting can be set per reader. When set to N, then one in every N*termIndexInterval terms in the index is loaded into memory. By setting this to a value > 1 you can reduce memory usage, at the expense of higher latency when loading a TermInfo. The default value is 1. NOTE: you must call this before the term index is loaded. If the index is already loaded, an IllegalStateException is thrown.
TermDocsOverloaded.  
TermPositionsOverloaded.  
TermsOverloaded. Returns an enumeration of all the terms in the index. The enumeration is ordered by Term.compareTo(). Each term is greater than all that precede it in the enumeration. Note that after calling terms(), {@link TermEnum#Next()} must be called on the resulting enumeration before calling other methods such as {@link TermEnum#Term()}.
ToString (inherited from Object)Returns a String that represents the current Object.
UndeleteAllUndeletes all documents currently marked as deleted in this index.

Protected Instance Methods

Finalize (inherited from Object)Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
MemberwiseClone (inherited from Object)Creates a shallow copy of the current Object.

Protected Internal Instance Constructors

IndexReader Overloaded. Initializes a new instance of the IndexReader class.

Protected Internal Instance Fields

hasChanges 

Protected Internal Instance Methods

AcquireWriteLockDoes nothing by default. Subclasses that require a write lock for index modifications must implement this method.
DoCloseImplements close.
DoCommitImplements commit.
DoDeleteImplements deletion of the document numbered
docNum
. Applications should call {@link #DeleteDocument(int)} or {@link #DeleteDocuments(Term)}.
DoSetNormImplements setNorm in subclass.
DoUndeleteAllImplements actual undeleteAll() in subclass.

See Also

IndexReader Class | Lucene.Net.Index Namespace