IndexHighlight Method (FoundDocument, Highlighter) |
Namespace: GroupDocs.Search
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 }