SearchDocumentFilter

SearchOptions.SearchDocumentFilter 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.

public ISearchDocumentFilter SearchDocumentFilter { get; set; }

Property Value

The search document filter.

Examples

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
index.Add(documentsFolder);

// 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