C# Класс Lucene.Net.Index.IndexReader

IndexReader is an abstract class, providing an interface for accessing an index. Search of an index is done entirely through this abstract interface, so that any subclass which implements it is searchable.

There are two different types of IndexReaders:

  • AtomicReader: These indexes do not consist of several sub-readers, they are atomic. They support retrieval of stored fields, doc values, terms, and postings.
  • CompositeReader: Instances (like DirectoryReader) of this reader can only be used to get stored fields from the underlying AtomicReaders, but it is not possible to directly retrieve postings. To do that, get the sub-readers via CompositeReader#getSequentialSubReaders. Alternatively, you can mimic an AtomicReader (with a serious slowdown), by wrapping composite readers with SlowCompositeReaderWrapper.

IndexReader instances for indexes on disk are usually constructed with a call to one of the static DirectoryReader.open() methods, e.g. DirectoryReader#open(Lucene.Net.Store.Directory). DirectoryReader implements the CompositeReader interface, it is not possible to directly get postings.

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: {@link 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.

Наследование: IDisposable
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
DEFAULT_TERMS_INDEX_DIVISOR int
hasChanges bool

Открытые методы

Метод Описание
Clone ( bool openReadOnly ) : IndexReader

Clones the IndexReader and optionally changes readOnly. A readOnly reader cannot open a writeable reader.

Clone ( ) : Object

Efficiently clones the IndexReader (sharing most internal state).

On cloning a reader with pending changes (deletions, norms), the original reader transfers its write lock to the cloned reader. This means only the cloned reader may make further changes to the index, and commit the changes to the index on close, but the old reader still reflects all changes made up until it was cloned.

Like Reopen(), it's safe to make changes to either the original or the cloned reader: all shared mutable state obeys "copy on write" semantics to ensure the changes are not seen by other readers.

Commit ( ) : void

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).

Commit ( string>.IDictionary commitUserData ) : void

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 ( ) : void

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.

DeleteDocument ( int docNum ) : void

Deletes 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 Document(int) method will result in an error. The presence of this document may still be reflected in the DocFreq statistic, though this will be corrected eventually as the index is further modified.

since this reader was opened

has this index open (write.lock could not be obtained)

DeleteDocuments ( Lucene.Net.Index.Term term ) : int

Deletes 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 DeleteDocument(int) for information about when this deletion will become effective.

since this reader was opened

has this index open (write.lock could not be obtained)

Directory ( ) : 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.

Dispose ( ) : void

Closes files associated with this index. Also saves any new deletions to disk. No other methods should be called after this has been called.

DocFreq ( Lucene.Net.Index.Term t ) : int

Returns the number of documents containing the term t.

Document ( int n ) : Lucene.Net.Documents.Document

Returns the stored fields of the nth Document in this index.

NOTE: for performance reasons, this method does not check if the requested document is deleted, and therefore asking for a deleted document may yield unspecified results. Usually this is not required, however you can call IsDeleted(int) with the requested document ID to verify the document is not deleted.

Document ( int n, Lucene.Net.Documents.FieldSelector fieldSelector ) : Lucene.Net.Documents.Document

Get the Lucene.Net.Documents.Document at the n th position. The FieldSelector may be used to determine what Lucene.Net.Documents.Fields to load and how they should be loaded. NOTE: If this Reader (more specifically, the underlying FieldsReader) is closed before the lazy Lucene.Net.Documents.Field is loaded an exception may be thrown. If you want the value of a lazy Lucene.Net.Documents.Field to be available after closing you must explicitly load it or fetch the Document again with a new loader.

NOTE: for performance reasons, this method does not check if the requested document is deleted, and therefore asking for a deleted document may yield unspecified results. Usually this is not required, however you can call IsDeleted(int) with the requested document ID to verify the document is not deleted.

Flush ( ) : void

Flush ( string>.IDictionary commitUserData ) : void
GetCommitUserData ( Directory directory ) : IDictionary,System.Collections.Generic

Reads commitUserData, previously passed to IndexWriter.Commit(System.Collections.Generic.IDictionary{string, string}), from current index segments file. This will return null if IndexWriter.Commit(System.Collections.Generic.IDictionary{string, string}) has never been called for this index.

GetCurrentVersion ( Directory directory ) : long

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.

GetFieldNames ( FieldOption fldOption ) : ICollection

Get a list of unique field names that exist in this index and have the specified field option information.

GetSequentialSubReaders ( ) : Lucene.Net.Index.IndexReader[]

Expert: returns the sequential sub readers that this reader is logically composed of. For example, IndexSearcher uses this API to drive searching by one sub reader at a time. If this reader is not composed of sequential child readers, it should return null. If this method returns an empty array, that means this reader is a null reader (for example a MultiReader that has no sub readers).

NOTE: You should not try using sub-readers returned by this method to make any changes (setNorm, deleteDocument, etc.). While this might succeed for one composite reader (like MultiReader), it will most likely lead to index corruption for other readers (like DirectoryReader obtained through IndexReader.Open(Lucene.Net.Store.Directory,bool). Use the parent reader directly.

GetTermFreqVector ( int docNumber, String field ) : ITermFreqVector

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 TermPositionVector is returned.

GetTermFreqVector ( int docNumber, String field, Lucene.Net.Index.TermVectorMapper mapper ) : void

Load the Term Vector into a user-defined data structure instead of relying on the parallel arrays of the ITermFreqVector.

GetTermFreqVector ( int docNumber, Lucene.Net.Index.TermVectorMapper mapper ) : void

Map all the term vectors for all fields in a Document

GetTermFreqVectors ( int docNumber ) : ITermFreqVector[]

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 may either be of type ITermFreqVector or of type TermPositionVector if positions or offsets have been stored.

HasNorms ( System field ) : bool

Returns true if there are norms stored for this field.

IncRef ( ) : void

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 DecRef, in a finally clause; otherwise the reader may never be closed. Note that Close simply calls decRef(), which means that the IndexReader will not really be closed until DecRef has been called for all outstanding references.

IndexExists ( Directory directory ) : bool

Returns true if an index exists at the specified directory. If the directory does not exist or if there is no index in it.

IsCurrent ( ) : bool

Check whether any new changes have occurred to the index since this reader was opened.

If this reader is based on a Directory (ie, was created by calling Open(Store.Directory) , or Reopen() on a reader based on a Directory), then this method checks if any further commits (see IndexWriter.Commit() have occurred in that directory).

If instead this reader is a near real-time reader (ie, obtained by a call to IndexWriter.GetReader(), or by calling Reopen() on a near real-time reader), then this method checks if either a new commmit has occurred, or any new uncommitted changes have taken place via the writer. Note that even if the writer has only performed merging, this method will still return false.

In any event, if this returns false, you should call Reopen() to get a new reader that sees the changes.

IsDeleted ( int n ) : bool

Returns true if document n has been deleted

IsOptimized ( ) : bool

Checks is the index is optimized (if it has a single segment and no deletions). Not implemented in the IndexReader base class.

LastModified ( Directory directory2 ) : long

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 IsCurrent() instead.

ListCommits ( Directory dir ) : System.Collections.Generic.ICollection

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 IndexReader.Open(IndexCommit,bool) There must be at least one commit in the Directory, else this method throws System.IO.IOException. Note that if a commit is in progress while this method is running, that commit may or may not be returned array.

Norms ( System field ) : byte[]

Returns the byte-encoded normalization factor for the named field of every document. This is used by the search code to score documents.

Norms ( System field, byte bytes, int offset ) : void

Reads the byte-encoded normalization factor for the named field of every document. This is used by the search code to score documents.

Open ( Directory directory, IndexDeletionPolicy deletionPolicy, bool readOnly ) : IndexReader

Expert: returns an IndexReader reading the index in the given Directory, with a custom IndexDeletionPolicy . You should pass readOnly=true, since it gives much better concurrent performance, unless you intend to do write operations (delete documents or change norms) with the reader.

Open ( Directory directory, IndexDeletionPolicy deletionPolicy, bool readOnly, int termInfosIndexDivisor ) : IndexReader

Expert: returns an IndexReader reading the index in the given Directory, with a custom IndexDeletionPolicy . You should pass readOnly=true, since it gives much better concurrent performance, unless you intend to do write operations (delete documents or change norms) with the reader.

Open ( Directory directory, bool readOnly ) : IndexReader

Returns an IndexReader reading the index in the given Directory. You should pass readOnly=true, since it gives much better concurrent performance, unless you intend to do write operations (delete documents or change norms) with the reader.

Open ( IndexCommit commit, IndexDeletionPolicy deletionPolicy, bool readOnly ) : IndexReader

Expert: returns an IndexReader reading the index in the given Directory, using a specific commit and with a custom IndexDeletionPolicy. You should pass readOnly=true, since it gives much better concurrent performance, unless you intend to do write operations (delete documents or change norms) with the reader.

Open ( IndexCommit commit, IndexDeletionPolicy deletionPolicy, bool readOnly, int termInfosIndexDivisor ) : IndexReader

Expert: returns an IndexReader reading the index in the given Directory, using a specific commit and with a custom IndexDeletionPolicy. You should pass readOnly=true, since it gives much better concurrent performance, unless you intend to do write operations (delete documents or change norms) with the reader.

Open ( IndexCommit commit, bool readOnly ) : IndexReader

Expert: returns an IndexReader reading the index in the given IndexCommit. You should pass readOnly=true, since it gives much better concurrent performance, unless you intend to do write operations (delete documents or change norms) with the reader.

Reopen ( ) : IndexReader

Refreshes an IndexReader if the index has changed since this instance was (re)opened.

Opening an IndexReader is an expensive operation. This method can be used to refresh an existing IndexReader to reduce these costs. This method tries to only load segments that have changed or were created after the IndexReader was (re)opened.

If the index has not changed since this instance was (re)opened, then this call is a NOOP and returns this instance. Otherwise, a new instance is returned. The old instance is not closed and remains usable.

If the reader is reopened, even though they share resources internally, it's safe to make changes (deletions, norms) with the new reader. All shared mutable state obeys "copy on write" semantics to ensure the changes are not seen by other readers.

You can determine whether a reader was actually reopened by comparing the old instance with the instance returned by this method: IndexReader reader = ... ... IndexReader newReader = r.reopen(); if (newReader != reader) { ... // reader was reopened reader.close(); } reader = newReader; ... Be sure to synchronize that code so that other threads, if present, can never use reader after it has been closed and before it's switched to newReader.

NOTE: If this reader is a near real-time reader (obtained from IndexWriter.GetReader(), reopen() will simply call writer.getReader() again for you, though this may change in the future.

Reopen ( IndexCommit commit ) : IndexReader

Expert: reopen this reader on a specific commit point. This always returns a readOnly reader. If the specified commit point matches what this reader is already on, and this reader is already readOnly, then this same instance is returned; if it is not already readOnly, a readOnly clone is returned.

Reopen ( bool openReadOnly ) : IndexReader

Just like Reopen(), except you can change the readOnly of the original reader. If the index is unchanged but readOnly is different then a new reader will be returned.

SetNorm ( int doc, String field, byte value ) : void

Expert: Resets the normalization factor for the named field of the named document. The norm represents the product of the field's boost and its length normalization. Thus, to preserve the length normalization values when resetting this, one should base the new value upon the old. NOTE: If this field does not store norms, then this method call will silently do nothing.

since this reader was opened

has this index open (write.lock could not be obtained)

SetNorm ( int doc, System field, float value ) : void

Expert: Resets the normalization factor for the named field of the named document.

since this reader was opened

has this index open (write.lock could not be obtained)

TermDocs ( ) : TermDocs

Returns an unpositioned Lucene.Net.Index.TermDocs enumerator.

TermDocs ( Term term ) : TermDocs

Returns an enumeration of all the documents which contain term. For each document, the document number, the frequency of the term in that document is also provided, for use in search scoring. If term is null, then all non-deleted docs are returned with freq=1. Thus, this method implements the mapping:

Term    =>    <docNum, freq>*

The enumeration is ordered by document number. Each document number is greater than all that precede it in the enumeration.

TermPositions ( ) : TermPositions

Returns an unpositioned Lucene.Net.Index.TermPositions enumerator.

TermPositions ( Term term ) : TermPositions

Returns an enumeration of all the documents which contain term. For each document, in addition to the document number and frequency of the term in that document, a list of all of the ordinal positions of the term in the document is available. Thus, this method implements the mapping:

Term    =>    <docNum, freq, <pos1, pos2, ... posfreq-1> >*

This positional information facilitates phrase and proximity searching.

The enumeration is ordered by document number. Each document number is greater than all that precede it in the enumeration.

Terms ( ) : TermEnum

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(), TermEnum.Next() must be called on the resulting enumeration before calling other methods such as TermEnum.Term.

Terms ( Term t ) : TermEnum

Returns an enumeration of all terms starting at a given term. If the given term does not exist, the enumeration is positioned at the first term greater than the supplied term. The enumeration is ordered by Term.compareTo(). Each term is greater than all that precede it in the enumeration.

UndeleteAll ( ) : void

Undeletes all documents currently marked as deleted in this index.

since this reader was opened

has this index open (write.lock could not be obtained)

this ( int doc ) : Lucene.Net.Documents.Document

Returns the stored fields of the nth Document in this index.

NOTE: for performance reasons, this method does not check if the requested document is deleted, and therefore asking for a deleted document may yield unspecified results. Usually this is not required, however you can call IsDeleted(int) with the requested document ID to verify the document is not deleted.

Защищенные методы

Метод Описание
AcquireWriteLock ( ) : void

Does nothing by default. Subclasses that require a write lock for index modifications must implement this method.

Dispose ( bool disposing ) : void
DoClose ( ) : void

Implements close.

DoCommit ( string>.IDictionary commitUserData ) : void

Implements commit.

DoDelete ( int docNum ) : void

Implements deletion of the document numbered docNum. Applications should call DeleteDocument(int) or DeleteDocuments(Term).

DoSetNorm ( int doc, System field, byte value_Renamed ) : void

Implements setNorm in subclass.

DoUndeleteAll ( ) : void

Implements actual undeleteAll() in subclass.

EnsureOpen ( ) : void
IndexReader ( ) : System

Приватные методы

Метод Описание
Close ( ) : void
Main ( String args ) : void
NumDocs ( ) : int
Open ( Directory directory, IndexDeletionPolicy deletionPolicy, IndexCommit commit, bool readOnly, int termInfosIndexDivisor ) : IndexReader

Описание методов

AcquireWriteLock() защищенный Метод

Does nothing by default. Subclasses that require a write lock for index modifications must implement this method.
protected AcquireWriteLock ( ) : void
Результат void

Clone() публичный Метод

Clones the IndexReader and optionally changes readOnly. A readOnly reader cannot open a writeable reader.
public Clone ( bool openReadOnly ) : IndexReader
openReadOnly bool
Результат IndexReader

Clone() публичный Метод

Efficiently clones the IndexReader (sharing most internal state).

On cloning a reader with pending changes (deletions, norms), the original reader transfers its write lock to the cloned reader. This means only the cloned reader may make further changes to the index, and commit the changes to the index on close, but the old reader still reflects all changes made up until it was cloned.

Like Reopen(), it's safe to make changes to either the original or the cloned reader: all shared mutable state obeys "copy on write" semantics to ensure the changes are not seen by other readers.

public Clone ( ) : Object
Результат System.Object

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).
public Commit ( ) : void
Результат void

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).
public Commit ( string>.IDictionary commitUserData ) : void
commitUserData string>.IDictionary
Результат void

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.
public DecRef ( ) : void
Результат void

DeleteDocument() публичный Метод

Deletes 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 Document(int) method will result in an error. The presence of this document may still be reflected in the DocFreq statistic, though this will be corrected eventually as the index is further modified. since this reader was opened has this index open (write.lock could not be obtained)
public DeleteDocument ( int docNum ) : void
docNum int
Результат void

DeleteDocuments() публичный Метод

Deletes 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 DeleteDocument(int) for information about when this deletion will become effective. since this reader was opened has this index open (write.lock could not be obtained)
public DeleteDocuments ( Lucene.Net.Index.Term term ) : int
term Lucene.Net.Index.Term
Результат int

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.
public Directory ( ) : Directory
Результат System.IO.Directory

Dispose() публичный Метод

Closes files associated with this index. Also saves any new deletions to disk. No other methods should be called after this has been called.
public Dispose ( ) : void
Результат void

Dispose() защищенный Метод

protected Dispose ( bool disposing ) : void
disposing bool
Результат void

DoClose() защищенный абстрактный Метод

Implements close.
protected abstract DoClose ( ) : void
Результат void

DoCommit() защищенный абстрактный Метод

Implements commit.
protected abstract DoCommit ( string>.IDictionary commitUserData ) : void
commitUserData string>.IDictionary
Результат void

DoDelete() защищенный абстрактный Метод

Implements deletion of the document numbered docNum. Applications should call DeleteDocument(int) or DeleteDocuments(Term).
protected abstract DoDelete ( int docNum ) : void
docNum int
Результат void

DoSetNorm() защищенный абстрактный Метод

Implements setNorm in subclass.
protected abstract DoSetNorm ( int doc, System field, byte value_Renamed ) : void
doc int
field System
value_Renamed byte
Результат void

DoUndeleteAll() защищенный абстрактный Метод

Implements actual undeleteAll() in subclass.
protected abstract DoUndeleteAll ( ) : void
Результат void

DocFreq() публичный абстрактный Метод

Returns the number of documents containing the term t.
public abstract DocFreq ( Lucene.Net.Index.Term t ) : int
t Lucene.Net.Index.Term
Результат int

Document() публичный Метод

Returns the stored fields of the nth Document in this index.

NOTE: for performance reasons, this method does not check if the requested document is deleted, and therefore asking for a deleted document may yield unspecified results. Usually this is not required, however you can call IsDeleted(int) with the requested document ID to verify the document is not deleted.

public Document ( int n ) : Lucene.Net.Documents.Document
n int
Результат Lucene.Net.Documents.Document

Document() публичный абстрактный Метод

Get the Lucene.Net.Documents.Document at the n th position. The FieldSelector may be used to determine what Lucene.Net.Documents.Fields to load and how they should be loaded. NOTE: If this Reader (more specifically, the underlying FieldsReader) is closed before the lazy Lucene.Net.Documents.Field is loaded an exception may be thrown. If you want the value of a lazy Lucene.Net.Documents.Field to be available after closing you must explicitly load it or fetch the Document again with a new loader.

NOTE: for performance reasons, this method does not check if the requested document is deleted, and therefore asking for a deleted document may yield unspecified results. Usually this is not required, however you can call IsDeleted(int) with the requested document ID to verify the document is not deleted.

public abstract Document ( int n, Lucene.Net.Documents.FieldSelector fieldSelector ) : Lucene.Net.Documents.Document
n int Get the document at the nth position ///
fieldSelector Lucene.Net.Documents.FieldSelector The to use to determine what /// Fields should be loaded on the Document. May be null, in which case /// all Fields will be loaded. ///
Результат Lucene.Net.Documents.Document

EnsureOpen() защищенный Метод

protected EnsureOpen ( ) : void
Результат void

Flush() публичный Метод

public Flush ( ) : void
Результат void

Flush() публичный Метод

public Flush ( string>.IDictionary commitUserData ) : void
commitUserData string>.IDictionary Opaque Map (String -> String) /// that's recorded into the segments file in the index, /// and retrievable by ///. ///
Результат void

GetCommitUserData() публичный статический Метод

Reads commitUserData, previously passed to IndexWriter.Commit(System.Collections.Generic.IDictionary{string, string}), from current index segments file. This will return null if IndexWriter.Commit(System.Collections.Generic.IDictionary{string, string}) has never been called for this index.
public static GetCommitUserData ( Directory directory ) : IDictionary,System.Collections.Generic
directory System.IO.Directory where the index resides. ///
Результат IDictionary,System.Collections.Generic

GetCurrentVersion() публичный статический Метод

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.
public static GetCurrentVersion ( Directory directory ) : long
directory System.IO.Directory where the index resides. ///
Результат long

GetFieldNames() публичный абстрактный Метод

Get a list of unique field names that exist in this index and have the specified field option information.
public abstract GetFieldNames ( FieldOption fldOption ) : ICollection
fldOption FieldOption specifies which field option should be available for the returned fields ///
Результат ICollection

GetSequentialSubReaders() публичный Метод

Expert: returns the sequential sub readers that this reader is logically composed of. For example, IndexSearcher uses this API to drive searching by one sub reader at a time. If this reader is not composed of sequential child readers, it should return null. If this method returns an empty array, that means this reader is a null reader (for example a MultiReader that has no sub readers).

NOTE: You should not try using sub-readers returned by this method to make any changes (setNorm, deleteDocument, etc.). While this might succeed for one composite reader (like MultiReader), it will most likely lead to index corruption for other readers (like DirectoryReader obtained through IndexReader.Open(Lucene.Net.Store.Directory,bool). Use the parent reader directly.

public GetSequentialSubReaders ( ) : Lucene.Net.Index.IndexReader[]
Результат Lucene.Net.Index.IndexReader[]

GetTermFreqVector() абстрактный публичный Метод

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 TermPositionVector is returned.
abstract public GetTermFreqVector ( int docNumber, String field ) : ITermFreqVector
docNumber int document for which the term frequency vector is returned ///
field String field for which the term frequency vector is returned. ///
Результат ITermFreqVector

GetTermFreqVector() абстрактный публичный Метод

Load the Term Vector into a user-defined data structure instead of relying on the parallel arrays of the ITermFreqVector.
abstract public GetTermFreqVector ( int docNumber, String field, Lucene.Net.Index.TermVectorMapper mapper ) : void
docNumber int The number of the document to load the vector for ///
field String The name of the field to load ///
mapper Lucene.Net.Index.TermVectorMapper The to process the vector. Must not be null ///
Результат void

GetTermFreqVector() абстрактный публичный Метод

Map all the term vectors for all fields in a Document
abstract public GetTermFreqVector ( int docNumber, Lucene.Net.Index.TermVectorMapper mapper ) : void
docNumber int The number of the document to load the vector for ///
mapper Lucene.Net.Index.TermVectorMapper The to process the vector. Must not be null ///
Результат void

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 may either be of type ITermFreqVector or of type TermPositionVector if positions or offsets have been stored.
abstract public GetTermFreqVectors ( int docNumber ) : ITermFreqVector[]
docNumber int document for which term frequency vectors are returned ///
Результат ITermFreqVector[]

HasNorms() публичный Метод

Returns true if there are norms stored for this field.
public HasNorms ( System field ) : bool
field System
Результат bool

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 DecRef, in a finally clause; otherwise the reader may never be closed. Note that Close simply calls decRef(), which means that the IndexReader will not really be closed until DecRef has been called for all outstanding references.
public IncRef ( ) : void
Результат void

IndexExists() публичный статический Метод

Returns true if an index exists at the specified directory. If the directory does not exist or if there is no index in it.
public static IndexExists ( Directory directory ) : bool
directory System.IO.Directory the directory to check for an index ///
Результат bool

IndexReader() защищенный Метод

protected IndexReader ( ) : System
Результат System

IsCurrent() публичный Метод

Check whether any new changes have occurred to the index since this reader was opened.

If this reader is based on a Directory (ie, was created by calling Open(Store.Directory) , or Reopen() on a reader based on a Directory), then this method checks if any further commits (see IndexWriter.Commit() have occurred in that directory).

If instead this reader is a near real-time reader (ie, obtained by a call to IndexWriter.GetReader(), or by calling Reopen() on a near real-time reader), then this method checks if either a new commmit has occurred, or any new uncommitted changes have taken place via the writer. Note that even if the writer has only performed merging, this method will still return false.

In any event, if this returns false, you should call Reopen() to get a new reader that sees the changes.

public IsCurrent ( ) : bool
Результат bool

IsDeleted() публичный абстрактный Метод

Returns true if document n has been deleted
public abstract IsDeleted ( int n ) : bool
n int
Результат bool

IsOptimized() публичный Метод

Checks is the index is optimized (if it has a single segment and no deletions). Not implemented in the IndexReader base class.
public IsOptimized ( ) : bool
Результат bool

LastModified() публичный статический Метод

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 IsCurrent() instead.
public static LastModified ( Directory directory2 ) : long
directory2 Directory
Результат long

ListCommits() публичный статический Метод

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 IndexReader.Open(IndexCommit,bool) There must be at least one commit in the Directory, else this method throws System.IO.IOException. Note that if a commit is in progress while this method is running, that commit may or may not be returned array.
public static ListCommits ( Directory dir ) : System.Collections.Generic.ICollection
dir Directory
Результат System.Collections.Generic.ICollection

Norms() публичный абстрактный Метод

Returns the byte-encoded normalization factor for the named field of every document. This is used by the search code to score documents.
public abstract Norms ( System field ) : byte[]
field System
Результат byte[]

Norms() публичный абстрактный Метод

Reads the byte-encoded normalization factor for the named field of every document. This is used by the search code to score documents.
public abstract Norms ( System field, byte bytes, int offset ) : void
field System
bytes byte
offset int
Результат void

Open() публичный статический Метод

Expert: returns an IndexReader reading the index in the given Directory, with a custom IndexDeletionPolicy . You should pass readOnly=true, since it gives much better concurrent performance, unless you intend to do write operations (delete documents or change norms) with the reader.
public static Open ( Directory directory, IndexDeletionPolicy deletionPolicy, bool readOnly ) : IndexReader
directory Directory the index directory ///
deletionPolicy IndexDeletionPolicy a custom deletion policy (only used /// if you use this reader to perform deletes or to set /// norms); see for details. ///
readOnly bool true if no changes (deletions, norms) will be made with this IndexReader ///
Результат IndexReader

Open() публичный статический Метод

Expert: returns an IndexReader reading the index in the given Directory, with a custom IndexDeletionPolicy . You should pass readOnly=true, since it gives much better concurrent performance, unless you intend to do write operations (delete documents or change norms) with the reader.
public static Open ( Directory directory, IndexDeletionPolicy deletionPolicy, bool readOnly, int termInfosIndexDivisor ) : IndexReader
directory Directory the index directory ///
deletionPolicy IndexDeletionPolicy a custom deletion policy (only used /// if you use this reader to perform deletes or to set /// norms); see for details. ///
readOnly bool true if no changes (deletions, norms) will be made with this IndexReader ///
termInfosIndexDivisor int Subsamples which indexed /// terms are loaded into RAM. This has the same effect as /// 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. Set this /// to -1 to skip loading the terms index entirely. ///
Результат IndexReader

Open() публичный статический Метод

Returns an IndexReader reading the index in the given Directory. You should pass readOnly=true, since it gives much better concurrent performance, unless you intend to do write operations (delete documents or change norms) with the reader.
CorruptIndexException if the index is corrupt IOException if there is a low-level IO error
public static Open ( Directory directory, bool readOnly ) : IndexReader
directory Directory the index directory
readOnly bool true if no changes (deletions, norms) will be made with this IndexReader
Результат IndexReader

Open() публичный статический Метод

Expert: returns an IndexReader reading the index in the given Directory, using a specific commit and with a custom IndexDeletionPolicy. You should pass readOnly=true, since it gives much better concurrent performance, unless you intend to do write operations (delete documents or change norms) with the reader.
public static Open ( IndexCommit commit, IndexDeletionPolicy deletionPolicy, bool readOnly ) : IndexReader
commit IndexCommit the specific to open; /// see to list all commits /// in a directory ///
deletionPolicy IndexDeletionPolicy a custom deletion policy (only used /// if you use this reader to perform deletes or to set /// norms); see for details. ///
readOnly bool true if no changes (deletions, norms) will be made with this IndexReader ///
Результат IndexReader

Open() публичный статический Метод

Expert: returns an IndexReader reading the index in the given Directory, using a specific commit and with a custom IndexDeletionPolicy. You should pass readOnly=true, since it gives much better concurrent performance, unless you intend to do write operations (delete documents or change norms) with the reader.
public static Open ( IndexCommit commit, IndexDeletionPolicy deletionPolicy, bool readOnly, int termInfosIndexDivisor ) : IndexReader
commit IndexCommit the specific to open; /// see to list all commits /// in a directory ///
deletionPolicy IndexDeletionPolicy a custom deletion policy (only used /// if you use this reader to perform deletes or to set /// norms); see for details. ///
readOnly bool true if no changes (deletions, norms) will be made with this IndexReader ///
termInfosIndexDivisor int Subsambles which indexed /// terms are loaded into RAM. This has the same effect as /// 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. Set this /// to -1 to skip loading the terms index entirely. ///
Результат IndexReader

Open() публичный статический Метод

Expert: returns an IndexReader reading the index in the given IndexCommit. You should pass readOnly=true, since it gives much better concurrent performance, unless you intend to do write operations (delete documents or change norms) with the reader.
public static Open ( IndexCommit commit, bool readOnly ) : IndexReader
commit IndexCommit the commit point to open ///
readOnly bool true if no changes (deletions, norms) will be made with this IndexReader ///
Результат IndexReader

Reopen() публичный Метод

Refreshes an IndexReader if the index has changed since this instance was (re)opened.

Opening an IndexReader is an expensive operation. This method can be used to refresh an existing IndexReader to reduce these costs. This method tries to only load segments that have changed or were created after the IndexReader was (re)opened.

If the index has not changed since this instance was (re)opened, then this call is a NOOP and returns this instance. Otherwise, a new instance is returned. The old instance is not closed and remains usable.

If the reader is reopened, even though they share resources internally, it's safe to make changes (deletions, norms) with the new reader. All shared mutable state obeys "copy on write" semantics to ensure the changes are not seen by other readers.

You can determine whether a reader was actually reopened by comparing the old instance with the instance returned by this method: IndexReader reader = ... ... IndexReader newReader = r.reopen(); if (newReader != reader) { ... // reader was reopened reader.close(); } reader = newReader; ... Be sure to synchronize that code so that other threads, if present, can never use reader after it has been closed and before it's switched to newReader.

NOTE: If this reader is a near real-time reader (obtained from IndexWriter.GetReader(), reopen() will simply call writer.getReader() again for you, though this may change in the future.

public Reopen ( ) : IndexReader
Результат IndexReader

Reopen() публичный Метод

Expert: reopen this reader on a specific commit point. This always returns a readOnly reader. If the specified commit point matches what this reader is already on, and this reader is already readOnly, then this same instance is returned; if it is not already readOnly, a readOnly clone is returned.
public Reopen ( IndexCommit commit ) : IndexReader
commit IndexCommit
Результат IndexReader

Reopen() публичный Метод

Just like Reopen(), except you can change the readOnly of the original reader. If the index is unchanged but readOnly is different then a new reader will be returned.
public Reopen ( bool openReadOnly ) : IndexReader
openReadOnly bool
Результат IndexReader

SetNorm() публичный Метод

Expert: Resets the normalization factor for the named field of the named document. The norm represents the product of the field's boost and its length normalization. Thus, to preserve the length normalization values when resetting this, one should base the new value upon the old. NOTE: If this field does not store norms, then this method call will silently do nothing. since this reader was opened has this index open (write.lock could not be obtained)
public SetNorm ( int doc, String field, byte value ) : void
doc int
field String
value byte
Результат void

SetNorm() публичный Метод

Expert: Resets the normalization factor for the named field of the named document. since this reader was opened has this index open (write.lock could not be obtained)
public SetNorm ( int doc, System field, float value ) : void
doc int
field System
value float
Результат void

TermDocs() публичный абстрактный Метод

Returns an unpositioned Lucene.Net.Index.TermDocs enumerator.
public abstract TermDocs ( ) : TermDocs
Результат TermDocs

TermDocs() публичный Метод

Returns an enumeration of all the documents which contain term. For each document, the document number, the frequency of the term in that document is also provided, for use in search scoring. If term is null, then all non-deleted docs are returned with freq=1. Thus, this method implements the mapping:

Term    =>    <docNum, freq>*

The enumeration is ordered by document number. Each document number is greater than all that precede it in the enumeration.

public TermDocs ( Term term ) : TermDocs
term Term
Результат TermDocs

TermPositions() публичный абстрактный Метод

Returns an unpositioned Lucene.Net.Index.TermPositions enumerator.
public abstract TermPositions ( ) : TermPositions
Результат TermPositions

TermPositions() публичный Метод

Returns an enumeration of all the documents which contain term. For each document, in addition to the document number and frequency of the term in that document, a list of all of the ordinal positions of the term in the document is available. Thus, this method implements the mapping:

Term    =>    <docNum, freq, <pos1, pos2, ... posfreq-1> >*

This positional information facilitates phrase and proximity searching.

The enumeration is ordered by document number. Each document number is greater than all that precede it in the enumeration.

public TermPositions ( Term term ) : TermPositions
term Term
Результат TermPositions

Terms() публичный абстрактный Метод

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(), TermEnum.Next() must be called on the resulting enumeration before calling other methods such as TermEnum.Term.
public abstract Terms ( ) : TermEnum
Результат TermEnum

Terms() публичный абстрактный Метод

Returns an enumeration of all terms starting at a given term. If the given term does not exist, the enumeration is positioned at the first term greater than the supplied term. The enumeration is ordered by Term.compareTo(). Each term is greater than all that precede it in the enumeration.
public abstract Terms ( Term t ) : TermEnum
t Term
Результат TermEnum

UndeleteAll() публичный Метод

Undeletes all documents currently marked as deleted in this index. since this reader was opened has this index open (write.lock could not be obtained)
public UndeleteAll ( ) : void
Результат void

this() публичный Метод

Returns the stored fields of the nth Document in this index.

NOTE: for performance reasons, this method does not check if the requested document is deleted, and therefore asking for a deleted document may yield unspecified results. Usually this is not required, however you can call IsDeleted(int) with the requested document ID to verify the document is not deleted.

public this ( int doc ) : Lucene.Net.Documents.Document
doc int
Результат Lucene.Net.Documents.Document

Описание свойств

DEFAULT_TERMS_INDEX_DIVISOR защищенное статическое свойство

protected static int DEFAULT_TERMS_INDEX_DIVISOR
Результат int

hasChanges защищенное свойство

protected bool hasChanges
Результат bool