Highlighting results in network
Leave feedback
Search results in the search network can be highlighted in the text of the found document using the Highlight method of the Searcher class.
The set of available classes for highlighting text, as well as the highlighting options, are identical to those used for highlighting search results in a single index. Please see also the Highlighting search results page.
The following code example demonstrates highlighting search results on the search network.
C#
Searcher searcher = node.Searcher;
FragmentHighlighter highlighter = new FragmentHighlighter(OutputFormat.PlainText);
HighlightOptions options = new HighlightOptions();
options.TermsAfter = 5;
options.TermsBefore = 5;
options.TermsTotal = 15;
searcher.Highlight(document, highlighter, options);
FragmentContainer[] result = highlighter.GetResult();
Console.WriteLine();
for (int i = 0; i < result.Length; i++)
{
FragmentContainer container = result[i];
if (container.Count == 0) continue;
string[] fragments = container.GetFragments();
Console.WriteLine(container.FieldName);
int count = Math.Min(fragments.Length, maxFragments);
for (int j = 0; j < count; j++)
{
Console.WriteLine("\t" + fragments[j]);
}
}
You may easily run the code from documentation articles and see the features in action in our GitHub examples:
Along with full featured .NET library we provide simple, but powerful free Apps.
You are welcome to search over your PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX and more with our free online Free Online Document Search App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.