SearchOptionsSearchDocumentFilter Property
Gets or sets the search document filter. SearchDocumentFilter works on the inclusion logic. Use SearchDocumentFilter class for creation of a search document filter instances. The default value is null, which means that all found documents will be returned.

Namespace: GroupDocs.Search.Options
Assembly: GroupDocs.Search (in GroupDocs.Search.dll) Version: 21.8
public ISearchDocumentFilter SearchDocumentFilter { get; set; }

Property Value

Type: ISearchDocumentFilter
The search document filter.
The example demonstrates how to set the document filter.
string indexFolder = @"c:\MyIndex\";
string documentsFolder = @"c:\MyDocuments1\";

// Creating an index in the specified folder
Index index = new Index(indexFolder);

// Indexing documents

// Creating a search document filter that skips documents with extensions '.doc', '.docx', '.rtf'
SearchOptions options = new SearchOptions();
ISearchDocumentFilter fileExtensionFilter = SearchDocumentFilter.CreateFileExtension(".doc", ".docx", ".rtf"); // Creating file extension filter
ISearchDocumentFilter invertedFilter = SearchDocumentFilter.CreateNot(fileExtensionFilter); // Inverting file extension filter
options.SearchDocumentFilter = invertedFilter;

// Search in index
SearchResult result = index.Search("Einstein", options);
See Also