Index

Index class

Represents the main class for indexing documents and searching through them.

public class Index : IDisposable

Constructors

Name Description
Index() Initializes a new instance of the Index class in memory.
Index(IndexSettings) Initializes a new instance of the Index class in memory with particular index settings.
Index(string) Initializes a new instance of the Index class. Creates a new or opens an existing index on disk.
Index(string, bool) Initializes a new instance of the Index class. Loads an existing index from disk if overwriteIfExists is false; creates a new index on disk otherwise.
Index(string, IndexSettings) Initializes a new instance of the Index class. Creates a new index with particular settings or opens an existing index on disk.
Index(string, IndexSettings, bool) Initializes a new instance of the Index class. Loads an existing index from disk if overwriteIfExists is false; creates a new index on disk with particular index settings otherwise.

Properties

Name Description
Dictionaries { get; } Gets the dictionary repository.
Events { get; } Gets the event hub for subscribing to events.
IndexInfo { get; } Gets the basic information on the index.
IndexSettings { get; } Gets the index settings.
Repository { get; } Gets the index repository object if the index is contained in it.

Methods

Name Description
static LoadIntoMemoryCompletely(string) Loads the entire index into memory. Any changes to the index are not automatically saved to the original folder.
static LoadIntoMemoryCompletely(string, IndexSettings) Loads the entire index into memory. Any changes to the index are not automatically saved to the original folder.
Add(string) Performs an indexing operation. Adds a file or folder by an absolute or relative path. Documents from all subfolders will be indexed.
Add(string[]) Performs an indexing operation. Adds files or folders by an absolute or relative path. Documents from all subfolders will be indexed.
Add(Document[], IndexingOptions) Performs an indexing operation. Adds documents from file system, stream or structure.
Add(ExtractedData[], IndexingOptions) Performs an indexing operation. Adds the extracted data to the index.
Add(string, IndexingOptions) Performs an indexing operation. Adds a file or folder by an absolute or relative path. Documents from all subfolders will be indexed.
Add(string[], IndexingOptions) Performs an indexing operation. Adds files or folders by an absolute or relative path. Documents from all subfolders will be indexed.
ChangeAttributes(AttributeChangeBatch) Applies the specified batch of attribute changes to indexed documents without reindexing during the update operation.
CheckSegments(bool) Checks the index files for damage. The method repairs the index if fixIndexFunctionality is true; otherwise, it only reports the damage found.
Delete(string[], UpdateOptions) Deletes indexed files or folders from the index. The deleted documents are excluded from search immediately and are physically removed from the index when the index is optimized with Optimize. Note that an individual document cannot be deleted from the index if it was added to the index as part of a folder.
Delete(UpdateOptions, string[]) Deletes documents indexed from streams or structures. The deleted documents are excluded from search immediately and are physically removed from the index when the index is optimized with Optimize.
Dispose() Releases all resources used by the Index.
GetAttributes(string) Gets all the attributes associated with the specified indexed document.
GetDocumentText(DocumentInfo, OutputAdapter) Generates the text of an indexed document and passes it through an output adapter.
GetDocumentText(DocumentInfo, OutputAdapter, TextOptions) Generates the text of an indexed document with the specified options and passes it through an output adapter.
GetIndexedDocument(string) Gets an indexed document by document key.
GetIndexedDocumentItems(DocumentInfo) Gets an array of nested items of the specified document (for container documents such as ZIP, OST, PST).
GetIndexedDocuments() Gets an array of all indexed documents.
GetIndexedPaths() Gets an array of indexed paths - documents or folders.
GetIndexingReports() Gets the reports on indexing operations.
GetSearchReports() Gets the reports on search operations.
Highlight(FoundDocument, Highlighter) Highlights the found terms in the text of the found document using the specified highlighter.
Highlight(FoundDocument, Highlighter, HighlightOptions) Highlights the found terms in the text of the found document using the specified highlighter.
Merge(Index, MergeOptions) Merges the specified index into the current index. Note that the other index will not be changed.
Merge(IndexRepository, MergeOptions) Merges indexes from the specified index repository into the current index. Note that indexes in the repository will not be changed.
Notify(Notification) Passes the specified notification object to the index to perform the notification.
Optimize() Minimizes the number of index segments by merging them one with another. This operation improves search performance and physically removes deleted documents from the index. A very large index is optimized into several segments of limited size.
Optimize(MergeOptions) Minimizes the number of index segments by merging them one with another. This operation improves search performance and physically removes deleted documents from the index. A very large index is optimized into several segments of limited size.
SaveTo(string) Saves the in-memory index to disk. Also saves the regular index to another folder. Does not change the settings of this index.
Search(SearchQuery) Searches in the index.
Search(string) Searches in the index.
Search(SearchImage, ImageSearchOptions) Performs a reverse image search in the index.
Search(SearchQuery, SearchOptions) Searches in the index.
Search(string, SearchOptions) Searches in the index.
SearchNext(ChunkSearchToken) Continues the chunk search started with the Search method.
SearchNext(ChunkSearchToken, Cancellation) Continues the chunk search started with the Search method.
Update() Re-indexes documents that have been changed or deleted since the last update. Adds new files that have been added to the indexed folders.
Update(UpdateOptions) Re-indexes documents that have been changed or deleted since the last update. Adds new files that have been added to the indexed folders.

Remarks

A folder is used by one Index object at a time, in this process or in another one: a constructor that creates or opens an index in a folder that another Index object uses throws IOException. The folder is released when the index is disposed, or when the garbage collector finalizes an index that is not disposed. An index loaded into memory by LoadIntoMemoryCompletely does not use its folder.

Learn more

Examples

The example demonstrates a typical usage of the class.

string indexFolder = @"c:\MyIndex\";
string documentsFolder = @"c:\MyDocuments\";
string query = "Einstein";

Index index = new Index(indexFolder); // Creating index in the specified folder
index.Add(documentsFolder); // Indexing documents from the specified folder

SearchResult result = index.Search(query); // Searching in index

See Also