com.groupdocs.search.highlighters

Class HtmlHighlighter



  • public class HtmlHighlighter
    extends Highlighter

    Represents a search result highlighter that highlights search results in an entire document text formatted in HTML.

    Learn more

    The example demonstrates a typical usage of the class.

     String indexFolder = "c:\\MyIndex\\";
     String documentsFolder = "c:\\MyDocuments\\";
     // Creating an index
     Index index = new Index(indexFolder);
     // Indexing documents from the specified folder
     index.add(documentsFolder);
     // Search for the phase 'Theory of Relativity'
     SearchResult result = index.search("\"Theory of Relativity\"");
     // Highlighting found words in the text of a document
     FoundDocument document = result.getFoundDocument(0);
     OutputAdapter outputAdapter = new FileOutputAdapter("Highlighted.html");
     Highlighter highlighter = new HtmlHighlighter(outputAdapter);
     index.highlight(document, highlighter);
     
    • Constructor Detail

      • HtmlHighlighter

        public HtmlHighlighter(OutputAdapter outputAdapter)

        Initializes a new instance of the HtmlHighlighter class.

        Parameters:
        outputAdapter - The output adapter transferring a result of the highlighting.