IndexHighlight Method (FoundDocument, Highlighter)
Generates HTML formatted text with highlighted found terms.

Namespace: GroupDocs.Search
Assembly: GroupDocs.Search (in GroupDocs.Search.dll) Version: 20.11
Syntax
public void Highlight(
	FoundDocument document,
	Highlighter highlighter
)

Parameters

document
Type: GroupDocs.Search.ResultsFoundDocument
The found document.
highlighter
Type: GroupDocs.Search.HighlightersHighlighter
The search result highlighter.
Examples
The example demonstrates how to highlight occurrences in HTML formatted text.
C#
string indexFolder = @"c:\MyIndex\";
string documentFolder = @"c:\MyDocuments\";

// Creating an index
Index index = new Index(indexFolder);

// Indexing documents from the specified folder
index.Add(documentFolder);

// Search for the word 'eternity'
SearchResult result = index.Search("eternity");

// Highlighting occurrences in text
if (result.DocumentCount > 0)
{
    FoundDocument document = result.GetFoundDocument(0); // Getting the first found document
    OutputAdapter outputAdapter = new FileOutputAdapter(@"c:\Highlighted.html"); // Creating an output adapter to the file
    Highlighter highlighter = new HtmlHighlighter(outputAdapter); // Creating the highlighter object
    index.Highlight(document, highlighter); // Generating HTML formatted text with highlighted occurrences
}
See Also