Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active June 14, 2019 13:32
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/9219657f9f98d68c9719ccd7ca5fc5d2 to your computer and use it in GitHub Desktop.
Save GroupDocsGists/9219657f9f98d68c9719ccd7ca5fc5d2 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-Java
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
//Filter filter3 will only accept TXT and DOC documents with text 'Tolkien' in file names
SearchParameters parameters = new SearchParameters();
ISearchDocumentFilter filter1 = SearchDocumentFilter.createFileExtension(".txt", ".doc");
ISearchDocumentFilter filter2 = SearchDocumentFilter.createFileNameRegularExpression("task");
ISearchDocumentFilter filter3 = SearchDocumentFilter.createConjunction(filter1, filter2);
parameters.setSearchDocumentFilter(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