Skip to main content

Module highlight

Module highlight 

Source
Expand description

Search-result highlighting.

Explicit analyzers process the complete source and query inputs, then highlight matching lossless terms at their original source offsets. Overlapping source spans are merged when rendering, so compound alternatives and rewritten terms do not produce nested markers.

Without an analyzer, the helper scans Unicode words and compares their lower-case forms. The word-scanning entry point also preserves the existing SQL highlighting behavior.

use uqa_analysis::{highlight, HighlightOptions};

let out = highlight(
    "the quick brown fox jumps over the lazy dog",
    &["fox".into(), "dog".into()],
    None,
    &HighlightOptions::default(),
).unwrap();
assert!(out.contains("<b>fox</b>"));
assert!(out.contains("<b>dog</b>"));

Structs§

HighlightOptions
Per-call configuration. Defaults use <b> / </b> tags, a full-text highlight with no fragment cap, and 150-char fragments when max_fragments > 0.

Functions§

highlight
Highlight complete source spans with an explicit analyzer, or lowercase word matches when omitted.
highlight_budgeted
Highlight with one allowance for analysis, matching, fragment selection, and returned text.
highlight_compiled
Highlight original source spans using one immutable analyzer for the source and each complete query input.
highlight_compiled_budgeted
Retain one runtime allowance through complete-source analysis and source-span rendering.
highlight_words
Highlight independently analyzed source words, retaining the legacy word-scanning contract.
highlight_words_budgeted
Highlight independently analyzed source words with one runtime allocation allowance.