Skip to content

fix(search): correct vchord BM25 score direction#1453

Merged
nicoloboschi merged 1 commit intovectorize-io:mainfrom
liling:fix/vchord-bm25-score-direction
May 5, 2026
Merged

fix(search): correct vchord BM25 score direction#1453
nicoloboschi merged 1 commit intovectorize-io:mainfrom
liling:fix/vchord-bm25-score-direction

Conversation

@liling
Copy link
Copy Markdown
Contributor

@liling liling commented May 5, 2026

Summary

  • Negate vchord's <&> BM25 distance operator so that higher scores mean higher relevance, matching pg_textsearch behavior

The <&> operator returns a distance metric (lower = more relevant), but the code used DESC ordering, causing the least relevant results to appear first.

Test plan

  • Configure HINDSIGHT_API_TEXT_SEARCH_EXTENSION=vchord
  • Run a recall query and verify relevant results appear first
  • Switch to pg_textsearch and verify ordering remains correct

The `<&>` operator returns a distance metric where lower values mean
higher relevance, but the code was using DESC ordering, causing the
least relevant results to appear first. Negate the distance to get a
proper score (higher = more relevant), matching pg_textsearch behavior.
Copy link
Copy Markdown
Collaborator

@nicoloboschi nicoloboschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1!

@nicoloboschi nicoloboschi merged commit b322b0c into vectorize-io:main May 5, 2026
@liling liling deleted the fix/vchord-bm25-score-direction branch May 5, 2026 14:02
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