This page contains a description of all search options that can be specified in an instance of the SearchOptions class. If no search options are passed to the Search method, the default values described below are used.
Cancellation property
The Cancellation property allows you to specify the object to cancel the search operation. The search can be canceled without delay by calling the Cancel method or by calling the CancelAfter method with the delay in milliseconds as an argument. The default value is null, which means that the search cannot be canceled. To cancel the continuation of a search by chunks, pass the cancellation object to the SearchNext method (see the Search by chunks page).
DateFormats property
The DateFormats property allows you to specify formats for the date range search feature. By default, the collection contains the formats ‘dd.MM.yyyy’, ‘MM/dd/yyyy’, and ‘yyyy-MM-dd’. For details, see the Date range search page.
FuzzySearch property
The FuzzySearch property returns a fuzzy search options object that allows you to enable fuzzy search and set its options. By default, the fuzzy search feature is disabled. For details, see the Fuzzy search page.
IsChunkSearch property
The IsChunkSearch property allows you to enable search by chunks. By default, the search by chunks feature is disabled. For details, see the Search by chunks page.
KeyboardLayoutCorrector property
The KeyboardLayoutCorrector property returns a keyboard layout corrector options object, which allows you to enable keyboard layout correction in search queries. By default, the keyboard layout correction feature is disabled. See the Keyboard layout correction page for details.
MaxOccurrenceCountPerTerm property
The MaxOccurrenceCountPerTerm property allows you to specify the maximum number of occurrences of each word found that will be returned as a search result. The default value is 2000000000.
MaxTotalOccurrenceCount property
The MaxTotalOccurrenceCount property allows you to specify the maximum number of occurrences in total for all found words, which will be returned as a search result. The default value is 2000000000.
RetrieveAttributes property
The RetrieveAttributes property allows you to retrieve the attributes associated with the found documents. If the property is set to true, the attributes of each found document are available in the FoundDocument.Attributes property; otherwise, this property returns an empty array. The default value is false. For details on document attributes, see the Document attributes page.
C#
stringindexFolder=@"c:\MyIndex\";stringdocumentsFolder=@"c:\MyDocuments\";stringquery="Einstein";// Creating an index in the specified folderIndexindex=newIndex(indexFolder);// Indexing documents from the specified folderindex.Add(documentsFolder);// Creating a search options instanceSearchOptionsoptions=newSearchOptions();options.RetrieveAttributes=true;// Enabling the retrieval of document attributes// Search in the indexSearchResultresult=index.Search(query,options);// Printing the attributes of the found documentsfor(inti=0;i<result.DocumentCount;i++){FoundDocumentdocument=result.GetFoundDocument(i);Console.WriteLine(document.DocumentInfo.FilePath+": "+string.Join(", ",document.Attributes));}
SearchDocumentFilter property
The SearchDocumentFilter property allows you to specify the filter of documents returned as a search result. By default, all documents found will be returned as a search result. For details, see the Document filtering in search result page.
SpellingCorrector property
The SpellingCorrector property returns the spelling corrector options object, which allows you to enable spelling correction in search queries and specify spelling correction options. By default, spelling correction is disabled. See the Spell checking page for details.
UseCaseSensitiveSearch property
The UseCaseSensitiveSearch property allows you to perform case-sensitive search. Please note that case-sensitive search cannot be combined with fuzzy search, synonym search, homophone search, word forms search, spelling correction, and keyboard layout correction (see Incompatible options below). By default, case-insensitive search is performed. For details, see the Case sensitive search page.
UseHomophoneSearch property
The UseHomophoneSearch property allows you to enable the homophone search feature. By default, the homophone search feature is disabled. For details, see the Homophone search page.
UseSynonymSearch property
The UseSynonymSearch property allows you to enable the synonym search feature. By default, the synonym search feature is disabled. For details, see the Synonym search page.
UseWordFormsSearch property
The UseWordFormsSearch property allows you to enable the word forms search feature. By default, the word forms search feature is disabled. For details, see the Search for different word forms page.
Incompatible options
The search options are checked when a search starts. In the following cases, the Search method does not throw an exception: it returns an empty search result and raises the ErrorOccurred event of the index with a message describing the problem:
Case-sensitive search is enabled together with fuzzy search, synonym search, homophone search, word forms search, spelling correction, or keyboard layout correction.
Synonym search is enabled, but the synonym dictionary of the index is empty.
Homophone search is enabled, but the homophone dictionary of the index is empty.
A search query in text form with a syntax error is handled in the same way: the search returns an empty result, and the error message is passed to the ErrorOccurred event. Therefore, it is recommended to subscribe to the ErrorOccurred event to receive such messages. For details on index events, see the Search index events page.
C#
stringindexFolder=@"c:\MyIndex\";stringdocumentsFolder=@"c:\MyDocuments\";stringquery="Einstein";// Creating an index in the specified folderIndexindex=newIndex(indexFolder);// Subscribing to the event of errorsindex.Events.ErrorOccurred+=(sender,args)=>{Console.WriteLine(args.Message);};// Indexing documents from the specified folderindex.Add(documentsFolder);// Creating a search options instance with incompatible optionsSearchOptionsoptions=newSearchOptions();options.UseCaseSensitiveSearch=true;options.FuzzySearch.Enabled=true;// The search returns an empty result, and the ErrorOccurred event reports the reasonSearchResultresult=index.Search(query,options);Console.WriteLine("Document count: "+result.DocumentCount);
More resources
GitHub examples
You may easily run the code from documentation articles and see the features in action in our GitHub examples: