DocumentHighlighter

DocumentHighlighter class

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

public class DocumentHighlighter : Highlighter

Constructors

Name Description
DocumentHighlighter(OutputAdapter) Initializes a new instance of the DocumentHighlighter class.

Properties

Name Description
OutputAdapter { get; } Gets the output adapter passed in the constructor.
OutputFormat { get; } Gets the output format.

Remarks

Learn more

Examples

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);

See Also