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§
- Active
Files - 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 — abazoutsideFoo::Baris 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 abazelsewhere 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_otheris the top score among the other results (Nonewhen this is the only one). Rounded to two decimals. - live_
search - Layer 4: scan
rootlive (no index required) and return ranked hits. Results are treated as the current repo, so the current-repo boost applies.skipnames already-indexed files to ignore, anddeadlinebounds the scan — both empty/Nonefor an unbounded scan of a never-indexed directory. Whenprefilteris set, only files containing the query (substring) are parsed — fast for exact/prefix/substring queries, but blind to fuzzy abbreviations, so callers retry withprefilter = falseif a filtered scan finds nothing. - match_
positions - The char indices in
namethatquerymatched, from the best alignment — for highlighting what matched. Empty ifqueryisn’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.rb→user. - search
- Search the index for
query, returning up tolimitranked 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;activeboosts files you’re changing on the current branch.