Skip to content

fix(search): dedupe repeated query tokens - #678

Closed
quifox wants to merge 2 commits into
nicobailon:mainfrom
quifox:fix/search-ranking-duplicate-query-tokens
Closed

quifox wants to merge 2 commits into
nicobailon:mainfrom
quifox:fix/search-ranking-duplicate-query-tokens

Conversation

@quifox

@quifox quifox commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • dedupe query tokens before token scoring and coverage checks
  • prevent repeated terms such as search search from being treated as partially unmatched
  • add a regression test and changelog entry

Problem

matchedTokens is a Set, while coverage used the original queryTokens.length. For a query like search search, the matched-token numerator was deduplicated to 1 while the denominator remained 2, producing 50% coverage and filtering an otherwise matching tool.

Validation

  • npx vitest run __tests__/search-ranking.test.ts
  • npm run typecheck

The focused regression test fails on current main before the fix and passes with this change.

@greptile-apps

greptile-apps Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Changes how search queries rank matching tools.

The PR appears safe to merge.

Summary

The PR deduplicates query tokens before scoring and ranking, preventing repeated words from reducing match coverage.

  • Adds a regression assertion through both scoreToolMatch and rankToolMatches.
  • Documents the fix in the changelog.

Reviews (2) · Last reviewed commit: "test(search): cover repeated query token..."

Comment thread __tests__/search-ranking.test.ts Resolved
@nicobailon

Copy link
Copy Markdown
Owner

Thanks @kojizada490-wq — this fix landed in #686 on current main, preserving your implementation and adding changelog credit for your contribution.

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.

2 participants