The example demonstrates how to highlight occurrences in HTML formatted text.
stringindexFolder=@"c:\MyIndex\";stringdocumentFolder=@"c:\MyDocuments\";// Creating an indexIndexindex=newIndex(indexFolder);// Indexing documents from the specified folderindex.Add(documentFolder);// Search for the word 'eternity'SearchResultresult=index.Search("eternity");// Highlighting occurrences in textif(result.DocumentCount>0){FoundDocumentdocument=result.GetFoundDocument(0);// Getting the first found documentOutputAdapteroutputAdapter=newFileOutputAdapter(@"c:\Highlighted.html");// Creating an output adapter to the fileHighlighterhighlighter=newHtmlHighlighter(outputAdapter);// Creating the highlighter objectindex.Highlight(document,highlighter);// Generating HTML formatted text with highlighted occurrences}
The example demonstrates how to highlight occurrences in HTML formatted text.
stringindexFolder=@"c:\MyIndex\";stringdocumentFolder=@"c:\MyDocuments\";// Creating an indexIndexindex=newIndex(indexFolder);// Indexing documents from the specified folderindex.Add(documentFolder);// Search for the word 'eternity'SearchResultresult=index.Search("eternity");// Highlighting occurrences in textif(result.DocumentCount>0){FoundDocumentdocument=result.GetFoundDocument(0);// Getting the first found documentOutputAdapteroutputAdapter=newFileOutputAdapter(@"c:\Highlighted.html");// Creating an output adapter to the fileHighlighterhighlighter=newHtmlHighlighter(outputAdapter);// Creating the highlighter objectHighlightOptionsoptions=newHighlightOptions();// Creating the highlight options objectoptions.TermsBefore=5;options.TermsAfter=5;options.TermsTotal=15;index.Highlight(document,highlighter,options);// Generating HTML formatted text with highlighted occurrences}