Skip to content

fix(search): rebalance scorer to prioritize fuzzy match over frecency - #3749

Open
senamakel wants to merge 1 commit into
atuinsh:mainfrom
senamakel:atuinsh-atuin-3702
Open

fix(search): rebalance scorer to prioritize fuzzy match over frecency#3749
senamakel wants to merge 1 commit into
atuinsh:mainfrom
senamakel:atuinsh-atuin-3702

Conversation

@senamakel

Copy link
Copy Markdown

Summary

Fixes #3702.

The daemon search scorer combined fuzzy_score + frecency with equal weight, allowing frecency (typically 0-200) to dominate the ranking and override fuzzy match quality. This caused queries like "foo bar" to rank scattered character matches (e.g., "foo ...b...a...r...") above genuine contiguous substring matches (e.g., "foo bar something"), even though the latter should be clearly better fuzzy matches.

As the maintainer noted in the issue, this "could be the search engine over-biasing for frecency over the fuzzy match" and suggested setting search.frecency_score_multiplier = 0 as a workaround.

Fix

Changed the scorer in crates/atuin-daemon/src/search/index.rs to use fuzzy_score as the primary sort key:

fuzzy_score.saturating_mul(1000).saturating_add(frecency.min(999))

This ensures fuzzy match quality is the primary ranking criterion, with frecency serving only as a tiebreaker for results with equal fuzzy relevance.

Verification

  • cargo fmt passes
  • cargo test -p atuin-daemon: 33 tests passed, 0 failed
  • cargo test -p atuin-client: 9 tests passed, 0 failed
  • cargo test -p atuin-nucleo: all tests passed

Closes #3702

The scorer in the daemon search index added fuzzy_score + frecency with
equal weight, allowing frecency (0-200) to dominate the ranking and
overriding fuzzy match quality. This caused queries like 'foo bar' to
rank 'foo ...b...a...r...' (scattered) above 'foo bar something'
(contiguous substring).

Fix: make fuzzy_score the primary sort key by multiplying it by 1000,
with frecency (capped at 999) as a tiebreaker. This ensures better
substring matches consistently rank higher regardless of frecency.
@greptile-apps

greptile-apps Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Rebalances daemon search ranking so fuzzy relevance is primary and frecency acts as a bounded tie-breaker.

  • Multiplies fuzzy scores by 1000.
  • Caps the frecency contribution at 999.

Confidence Score: 4/5

The high-frecency tie-breaking regression should be fixed before merging.

Unbounded configuration multipliers can produce frecency values above 999, but the new scorer collapses all of them to one value and lets unrelated fallback ordering decide equally fuzzy results.

Files Needing Attention: crates/atuin-daemon/src/search/index.rs

Important Files Changed

Filename Overview
crates/atuin-daemon/src/search/index.rs Implements fuzzy-primary scoring, but collapses distinct high frecency values and lacks ordering coverage for the new packed score.

Reviews (1): Last reviewed commit: "fix(search): rebalance scorer to priorit..." | Re-trigger Greptile

Comment thread crates/atuin-daemon/src/search/index.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: (daemon-)fuzzy search fails to prioritize longer substrings

1 participant