Last active
November 22, 2019 05:49
-
-
Save GroupDocsGists/1f391adf95ca5a55a79e03aa40b520c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string indexFolder = @"D://Samples/Index"; | |
string documentsFolder = @"D://Samples/Source/Index"; | |
// Creating index in the specified folder | |
Index index = new Index(indexFolder); | |
// Indexing documents from the specified folder | |
index.Add(documentsFolder); | |
// Searching in index | |
SearchResult result = index.Search("video"); | |
for (int i = 0; i < result.DocumentCount; i++) | |
{ | |
if (result.DocumentCount > 0) | |
{ | |
FoundDocument document = result.GetFoundDocument(i); // Getting the first found document | |
OutputAdapter outputAdapter = new FileOutputAdapter(@"D:\Highlighted" + i + ".html"); // Creating the output adapter to a file | |
HtmlHighlighter highlighter = new HtmlHighlighter(outputAdapter); // Creating the highlighter object | |
index.Highlight(document, highlighter); // Generating output HTML formatted document with highlighted search results | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment