Table of Contents

Class SearchHighlightResult

Namespace
LMKit.Document.Search
Assembly
LM-Kit.NET.dll

Contains the output of a search-and-highlight operation performed by SearchHighlightEngine. Includes both the highlighted document bytes and metadata about the matches found.

public sealed class SearchHighlightResult
Inheritance
SearchHighlightResult
Inherited Members

Examples

Example 1: Save highlighted PDF and inspect match metadata.

using LMKit.Document.Search;

SearchHighlightResult result = await SearchHighlightEngine.HighlightAsync( "invoice.pdf", "Total Due");

// Save the highlighted output. File.WriteAllBytes("invoice_highlighted.pdf", result.OutputData);

// Display result summary. Console.WriteLine($"MIME type : {result.OutputMimeType}"); Console.WriteLine($"Query : {result.Query}"); Console.WriteLine($"Mode : {result.SearchMode}"); Console.WriteLine($"Pages : {result.ScannedPages} / {result.PageCount}"); Console.WriteLine($"Matches : {result.TotalMatches}"); Console.WriteLine($"Capped : {result.LimitedByMaxResults}");

// Iterate over individual matches. foreach (TextMatch match in result.Matches) { Console.WriteLine($" Page {match.PageIndex + 1}: "{match.Text}" => ...{match.Snippet}..."); }

Example 2: Conditional processing based on result properties.

using LMKit.Document.Search;

var options = new SearchHighlightOptions { SearchMode = SearchMode.Fuzzy, MaxResults = 100 };

SearchHighlightResult result = await SearchHighlightEngine.HighlightAsync( "report.pdf", "recieve", options);

if (result.TotalMatches == 0) { Console.WriteLine("No matches found."); } else { File.WriteAllBytes("report_typos.pdf", result.OutputData);

if (result.LimitedByMaxResults)
{
    Console.WriteLine($"Warning: results capped at {options.MaxResults}. Increase MaxResults for full coverage.");
}

// Group matches by page.
var byPage = result.Matches.GroupBy(m => m.PageIndex);
foreach (var group in byPage)
{
    Console.WriteLine($"Page {group.Key + 1}: {group.Count()} matches");
}

}

Properties

LimitedByMaxResults

Gets a value indicating whether results were capped by MaxResults.

Matches

Gets all matches with their text, snippet, bounding box, page index, and relevance score.

OutputData

Gets the highlighted document as a byte array. For PDF input, this is a PDF with highlight annotations. For image input, this is a PNG with highlight overlays.

OutputMimeType

Gets the MIME type of OutputData. Typically "application/pdf" or "image/png".

PageCount

Gets the total number of pages in the source document.

Query

Gets the search query that was executed.

ScannedPages

Gets the number of pages that were scanned for matches.

SearchMode

Gets the search mode that was used.

TotalMatches

Gets the total number of matches found and highlighted.

Share