DocumentHighlighter
Contents
[
Hide
]
Inheritance: java.lang.Object, com.groupdocs.search.common.ResultBuilderFactory, com.groupdocs.search.highlighters.Highlighter
All Implemented Interfaces: com.groupdocs.search.highlighters.IDocumentHighlighter
public class DocumentHighlighter extends Highlighter implements IDocumentHighlighter
Represents a search result highlighter that highlights search results in an entire document text.
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(OutputFormat.Html, "Highlighted.html");
Highlighter highlighter = new DocumentHighlighter(outputAdapter);
index.highlight(document, highlighter);
Constructors
Constructor | Description |
---|---|
DocumentHighlighter(OutputAdapter outputAdapter) | Initializes a new instance of the DocumentHighlighter class. |
Methods
Method | Description |
---|---|
getOutputAdapter() | Gets the output adapter passed in the constructor. |
DocumentHighlighter(OutputAdapter outputAdapter)
public DocumentHighlighter(OutputAdapter outputAdapter)
Initializes a new instance of the DocumentHighlighter class.
Parameters:
Parameter | Type | Description |
---|---|---|
outputAdapter | OutputAdapter | The output adapter transferring a result of the highlighting. |
getOutputAdapter()
public final OutputAdapter getOutputAdapter()
Gets the output adapter passed in the constructor.
Returns: OutputAdapter - The output adapter passed in the constructor.