Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active June 11, 2019 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/4dfcdf9857e743254611fd918a2cbc86 to your computer and use it in GitHub Desktop.
Save GroupDocsGists/4dfcdf9857e743254611fd918a2cbc86 to your computer and use it in GitHub Desktop.
//For complete examples and data files, please go to https://github.com/groupdocs-search/GroupDocs.Search-for-.NET
string indexFolder = @"c:\MyIndex";
string documentFolder = @"c:\MyDocuments";
//Creating index
Index index = new Index(indexFolder);
//Adding documents to index
index.AddToIndex(documentFolder);
//Configuring document filter
//filter3 will only accept TXT and DOCX documents with text 'task' in file names
SearchParameters parameters = new SearchParameters();
ISearchDocumentFilter filter1 = SearchDocumentFilter.CreateFileExtension(".txt", ".docx");
ISearchDocumentFilter filter2 = SearchDocumentFilter.CreateFileNameRegularExpression("task");
ISearchDocumentFilter filter3 = SearchDocumentFilter.CreateConjunction(filter1, filter2);
parameters.SearchDocumentFilter = filter3;
//Searching
SearchResults results = index.Search("hobbit", parameters);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment