Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active November 22, 2019 05:49
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/1f391adf95ca5a55a79e03aa40b520c5 to your computer and use it in GitHub Desktop.
Save GroupDocsGists/1f391adf95ca5a55a79e03aa40b520c5 to your computer and use it in GitHub Desktop.
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