Search index settings

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Search MCP server lets your agent work with files on your machine; they are never uploaded. It runs in Docker: replace /path/to/documents with the folder it may use.

claude mcp add groupdocs-search -- docker run --rm -i -v /path/to/documents:/data ghcr.io/groupdocs-search/search-net-mcp:latest
Folders, licensing and more →

This page contains a description of all index settings that can be specified in an instance of the IndexSettings class.

An index settings object is passed to an Index constructor when a new index is created. The settings are saved in the index. When an existing index is opened, it uses the settings saved in it; only the CustomExtractors and Logger settings, which are not saved, are taken from the passed settings object. The settings of an opened index are available through the Index.IndexSettings property.

Some settings define how the text of documents is divided into terms, so they cannot be changed freely after the index is created:

For details, see the Index format and compatibility page.

CustomExtractors property

The CustomExtractors property returns a collection of custom text extractors that allows adding new extractors for supported or not supported formats. Custom extractors are not saved in an index, so they must be added each time the index is created or opened. A complete example of implementing a custom text extractor and using it to extract text is presented on the page Custom text extractors.

DocumentFilter property

The DocumentFilter property allows you to set a filter used to determine whether files being added to the index should be indexed. If a document added separately or located in an added folder does not match the filter, it is not indexed. The default value is null, which means that all added files will be indexed if their format is supported. The value can be changed at any time. Detailed information on creating and setting the document indexing filter can be found on the page Document filtering during indexing.

IndexType property

The IndexType property is used to specify the type of an index. The IndexType enumeration contains 3 values:

  • NormalIndex - the type of an index containing the content and metadata of the added documents. It supports all search features.
  • MetadataIndex - the type of an index containing only metadata of added documents. It supports all search features. An example of creating an index of this type is presented on the Indexing metadata of documents page.
  • CompactIndex - the type of an index containing the content and metadata of the added documents. It takes much less disk space, but does not support the phrase search and the date range search features.

The default value of this property is NormalIndex. The index type is fixed when the index is created.

InMemoryIndex property

The read-only property InMemoryIndex returns a value indicating whether an index is located in RAM or on disk. The value of this property is set indirectly when creating or loading an index. An index is created on disk when the path to the index folder is specified; otherwise, an index is created in memory. See the Search index location page for details.

Logger property

The Logger property allows you to specify in the index settings the logger used for logging index events and errors during its operation. The default value is null meaning that logging is not used. The logger is not saved in an index, so it must be assigned each time the index is created or opened. Detailed information on creating and assigning an index logger and the implementation of a custom logger is presented on the page Logging.

MaxIndexingReportCount property

The MaxIndexingReportCount property allows you to specify the maximum number of indexing reports stored in RAM for an index since it was created or loaded. The default value is 5. Detailed information on indexing reports is provided on the page Indexing reports.

MaxSearchReportCount property

The MaxSearchReportCount property allows you to specify the maximum number of search reports stored in RAM for an index since it was created or loaded. The default value is 10. Detailed information on search reports is provided on the page Search reports.

ReplaceUnpairedSurrogates property

The ReplaceUnpairedSurrogates property specifies how unpaired UTF-16 surrogate characters in the text of documents are processed during indexing. If the value is true, each unpaired surrogate character is replaced with the Unicode replacement character (U+FFFD), so the characters around it are not joined into a single term. If the value is false, unpaired surrogate characters are removed, as previous versions did.

The default value is true. The setting is fixed when the index is created. An index updated from a version earlier than 26.10 has this setting disabled.

SearchThreads property

The SearchThreads property allows you to set the number of threads used to search in an index. By default, this value is NumberOfThreads.Default, which means that the search is performed using as many threads as there are processor cores.

Since version 26.11, the value is the number of threads that all the searches of an index performed at the same time use together. A search runs on the thread that calls it. While fewer searches than this number run, the index helps their parallel parts (fuzzy search, wildcards, regular expressions, numeric ranges, spelling correction and image search) with threads of its own, so one search uses up to this number of threads; when as many searches run or more, each search runs on its own thread only. Thus, K searches performed at the same time use max(K, SearchThreads) threads, and no search waits for a free thread. A part of a search that is too small to gain from several threads, for example a fuzzy search with one mistake or a search of a small index, runs on the thread of the search. Previously, each search used this number of threads of its own.

The value can be changed at any time, also for an existing index through the Index.IndexSettings property. A search uses the value that is set when the search starts, and the new value is saved in the index. The setter throws ArgumentOutOfRangeException if the value is not a member of the NumberOfThreads enumeration.

The order of the words found by a regular expression, numeric range, fuzzy or spelling correction search does not depend on the number of threads: it is the order of a search in one thread, that is, the ordinal order of the words and, for the fuzzy search, the number of mistakes first. Therefore, the order of the found terms of a document (FoundDocumentField.Terms), the order of the words of the SearchPhaseCompleted event, and the occurrences that are discarded when a limit of occurrences is reached do not differ from run to run.

The following example demonstrates how to change the number of search threads of an existing index.

C#

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

// Opening an existing index
Index index = new Index(indexFolder);

// Changing the number of threads used for the search; the new value is saved in the index
index.IndexSettings.SearchThreads = NumberOfThreads.One;

// Searching using the new number of threads
SearchResult result = index.Search(query);

SkipBlendedOnlyTerms property

The SkipBlendedOnlyTerms property specifies whether terms that consist only of blended characters are skipped during indexing. For example, if the hyphen is a blended character, a standalone hyphen in the text is not indexed as a term when the value is true. This reduces the number of meaningless terms in the index.

The default value is true. The setting is fixed when the index is created. An index updated from a version earlier than 26.10 has this setting disabled.

The following example demonstrates how to create an index that keeps the terms consisting only of blended characters.

C#

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

// Creating index settings
IndexSettings settings = new IndexSettings();
settings.SkipBlendedOnlyTerms = false; // Keeping the terms consisting only of blended characters

// Creating an index with the specified settings
Index index = new Index(indexFolder, settings, true);

// Indexing documents from the specified folder
index.Add(documentsFolder);

TextStorageSettings property

The TextStorageSettings property allows you to specify the settings for saving the text of indexed documents in an index. The default value is null, which means that document texts are not stored. The setting is fixed when the index is created. Detailed information on saving the text of indexed documents in an index is presented on the page Storing text of indexed documents.

UseCharacterReplacements property

The UseCharacterReplacements property allows you to set the value indicating whether to perform character replacements during the indexing process or not. The default value is false. The value can be changed only while the index contains no documents and is not performing an operation; otherwise, InvalidOperationException is thrown. Details on replacing characters during indexing are provided on the page Character replacement during indexing.

UseFastLoading property

The UseFastLoading property, available since version 26.11, specifies whether an index stored on disk keeps additional data that makes its loading several times faster. This data takes additional disk space, which grows with the number of distinct words in the index. If disk space matters more than loading time, set the property to false: the index takes less disk space but loads longer. The default value is true.

The value can be changed at any time, also for an existing index that contains documents, through the Index.IndexSettings property:

  • When the value is changed to false, the data is deleted as soon as the new value is saved in the index. Data that cannot be deleted at that moment, for example because another process uses it, is deleted the next time the index is opened.
  • When the value is changed to true, the data is created the next time the index is opened or its indexed words are changed, for example by indexing, merging or optimization.

The new value is saved in the index at once or, if the index is performing an operation at that moment, when the operation is finished. An index in memory keeps no such data: the value applies when the index is saved to disk.

The following example demonstrates how to create an index that takes less disk space and how to make it load fast again later.

C#

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

// Creating index settings
IndexSettings settings = new IndexSettings();
settings.UseFastLoading = false; // The index takes less disk space but loads longer

// Creating an index with the specified settings
Index index = new Index(indexFolder, settings, true);

// Indexing documents from the specified folder
index.Add(documentsFolder);

// Closing the index
index.Dispose();

// Opening the index and making it load fast again; the data is created the next time the index is opened
index = new Index(indexFolder);
index.IndexSettings.UseFastLoading = true;

UseStopWords property

The UseStopWords property allows you to specify a value indicating whether to use stop words during indexing or not. Stop words are frequently used words that do not carry a semantic load, which are removed from an index to reduce its size. The default value for this property is true. The value can be changed only while the index contains no documents and is not performing an operation; otherwise, InvalidOperationException is thrown. Detailed information on stop words and their use is presented on the page Indexing with stop words.

More resources

GitHub examples

You may easily run the code from documentation articles and see the features in action in our GitHub examples:

Free online document search App

Along with full featured .NET library we provide simple, but powerful free Apps.

You are welcome to search over your PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX and more with our free online Free Online Document Search App.