Skip to main content

Module search

Module search 

Source
Expand description

Search — the staged ranking pipeline.

Layers 1–3 (exact/prefix, abbreviation-aware fuzzy, path) over the index, scored by an additive, --explain-able scorer. Layers 4–5 (live scan, opportunistic extraction) and true streaming/early-exit arrive in phase 2; for now the candidate set is gathered once and ranked.

Structs§

ActiveFiles
Files you’re working on this branch — those that differ from the trunk — plus the directories holding them. Symbols in those files (or their directory neighbors) get a branch boost. Empty on the trunk / outside git.
Boosts
Dynamic, context-dependent boosts computed by crate::search (which owns the time math and store lookups). Kept out of the pure match scoring so each signal can be added without threading more parameters.
Feature
One named contribution to a score.
Hit
A ranked search result. Serializes for --json / --ndjson.
Scored
A scored candidate: total plus the per-feature breakdown.

Functions§

apply_scope_gate
Scope gate for a qualified query (Foo::Bar#baz). When the user names an enclosing scope and at least one result actually sits in it, drop the rest — a baz outside Foo::Bar is noise next to the one inside it, the same way the relevance gate drops fuzzy near-matches beside an exact hit. When nothing matches the scope, the list is left untouched: the scope was a hint, and the definition may simply live somewhere we didn’t expect, so a baz elsewhere still surfaces rather than returning empty.
confidence
Presented confidence in [0,1]: match quality scaled by dominance — how much this result leads the strongest other one. A unique strong match → ~1.0; evenly-tied candidates → ~0.5 (rq isn’t sure which you mean); a lone weak fuzzy match stays low. best_other is the top score among the other results (None when this is the only one). Rounded to two decimals.
live_search
Layer 4: scan root live (no index required) and return ranked hits. Results are treated as the current repo, so the current-repo boost applies. skip names already-indexed files to ignore, and deadline bounds the scan — both empty/None for an unbounded scan of a never-indexed directory. When prefilter is set, only files containing the query (substring) are parsed — fast for exact/prefix/substring queries, but blind to fuzzy abbreviations, so callers retry with prefilter = false if a filtered scan finds nothing.
match_positions
The char indices in name that query matched, from the best alignment — for highlighting what matched. Empty if query isn’t a subsequence.
match_quality
Absolute match quality in [0,1] — how good the match itself is, independent of ranking boosts. The dominant term in confidence. Exact is certain; a prefix nearly so; a fuzzy/abbreviation match scales with its alignment; a path-only match (name didn’t match) is weak.
merge
Merge two ranked lists, de-duplicating by location and name (keeping the higher score), then re-rank and truncate. Used to blend index and live-scan results.
path_stem
The filename stem of a repo-relative path: last segment, extension dropped. app/models/user.rbuser.
search
Search the index for query, returning up to limit ranked hits. current_repo_id (if any) boosts results from the repository you’re in; only_repo (if any) restricts results to that repository, so a search inside a repo answers about that repo rather than leaking others you’ve indexed; active boosts files you’re changing on the current branch.