ENHANCE: Improve credential - search typo and abbreviation matching improved #18

Merged
kashish merged 4 commits from enhance/search/typo_match into main 2026-07-23 20:30:04 +00:00
Owner

Summary

Improve credential search typo tolerance and abbreviation matching.

This change addresses cases where transposed characters (e.g. crat vs cart) were not matched effectively, and improves matching for abbreviated queries such as gpat against git_personal_access_token.

Fixes #17

Functional Changes

  • Replaced the Levenshtein distance implementation with Damerau-Levenshtein distance.

    • Treats an adjacent character transposition as a single edit operation.
    • Improves matching for common typing errors such as cratcart.
  • Added a subsequence boost to string scoring.

    • Queries whose characters appear in order within the target string receive an additional asymptotic boost (SUBSEQ_BOOST = 0.4).
    • Improves abbreviation matching for queries such as gpat against git_personal_access_token.
  • Preserved the existing scoring hierarchy.

    • Exact match > Prefix match > Substring match > Ordered subsequence match > Fuzzy edit-distance match.

Bug Fixes

  • Fixed similarityScore returning NaN when both input strings were empty.

    • Empty strings are now treated as a perfect match (1.0).

Test Coverage

  • Added Damerau-Levenshtein tests for:

    • adjacent character transpositions (catrcart)
    • non-adjacent swaps to verify they are not treated as a single edit.
  • Added subsequence scoring tests to verify that:

    • ordered subsequences receive a boost
    • out-of-order character sequences score lower than in-order subsequences.
  • Added end-to-end ranking tests covering:

    • frequency-based ranking
    • recency-based ranking
    • prefix-vs-fuzzy ranking behavior
    • deterministic tie-breakers (access count and label ordering).
  • Added query composition tests to verify that:

    • a user-only query matches credentials by user
    • a combined label+user query scores higher than a label-only query.
  • Updated scoring-order tests to explicitly validate the boost hierarchy, including the new subsequence boost.

Impact

  • Better matching for transposed-character typos.
  • Better support for abbreviated queries.
  • More stable and predictable search result ordering.
  • Eliminates a NaN edge case in similarity scoring.
## Summary Improve credential search typo tolerance and abbreviation matching. This change addresses cases where transposed characters (e.g. `crat` vs `cart`) were not matched effectively, and improves matching for abbreviated queries such as `gpat` against `git_personal_access_token`. Fixes #17 ## Functional Changes * Replaced the Levenshtein distance implementation with Damerau-Levenshtein distance. * Treats an adjacent character transposition as a single edit operation. * Improves matching for common typing errors such as `crat` → `cart`. * Added a subsequence boost to string scoring. * Queries whose characters appear in order within the target string receive an additional asymptotic boost (`SUBSEQ_BOOST = 0.4`). * Improves abbreviation matching for queries such as `gpat` against `git_personal_access_token`. * Preserved the existing scoring hierarchy. * Exact match > Prefix match > Substring match > Ordered subsequence match > Fuzzy edit-distance match. ## Bug Fixes * Fixed `similarityScore` returning `NaN` when both input strings were empty. * Empty strings are now treated as a perfect match (`1.0`). ## Test Coverage * Added Damerau-Levenshtein tests for: * adjacent character transpositions (`catr` ↔ `cart`) * non-adjacent swaps to verify they are not treated as a single edit. * Added subsequence scoring tests to verify that: * ordered subsequences receive a boost * out-of-order character sequences score lower than in-order subsequences. * Added end-to-end ranking tests covering: * frequency-based ranking * recency-based ranking * prefix-vs-fuzzy ranking behavior * deterministic tie-breakers (access count and label ordering). * Added query composition tests to verify that: * a user-only query matches credentials by user * a combined label+user query scores higher than a label-only query. * Updated scoring-order tests to explicitly validate the boost hierarchy, including the new subsequence boost. ## Impact * Better matching for transposed-character typos. * Better support for abbreviated queries. * More stable and predictable search result ordering. * Eliminates a `NaN` edge case in similarity scoring.
kashish self-assigned this 2026-07-18 19:00:09 +00:00
kashish force-pushed enhance/search/typo_match from f252bca525 to 1af6d8f010 2026-07-18 19:11:38 +00:00 Compare
Author
Owner

Conducting manual testing for verifying that changes do help in regular use. If there are no issues found in usage with these changes over the next couple of days will merge this.

Conducting manual testing for verifying that changes do help in regular use. If there are no issues found in usage with these changes over the next couple of days will merge this.
Author
Owner

It seems like a significant step-up in terms of usability and accuracy.

It seems like a significant step-up in terms of usability and accuracy.
kashish changed title from Improve credential search typo and abbreviation matching to ENHANCE: Improve credential - search typo and abbreviation matching improved 2026-07-23 20:29:41 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
plutolab/kosh!18
No description provided.