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§
- Highlight
Options - Per-call configuration. Defaults use
<b>/</b>tags, a full-text highlight with no fragment cap, and 150-char fragments whenmax_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.