Skip to content

[Cosmos] Use deterministic ordinal ranks for hybrid-search RRF - #50940

Draft
Maya Painter (Maya-Painter) wants to merge 5 commits into
mainfrom
maya-painter-java-rrf-implementation
Draft

Maya Painter (Maya-Painter) wants to merge 5 commits into
mainfrom
maya-painter-java-rrf-implementation

Conversation

@Maya-Painter

Copy link
Copy Markdown

Description

Ports the ranking behavior from merged Azure/azure-cosmos-dotnet-v3#6130 to the Java Cosmos hybrid-search pipeline.

Component scores 10, 5, 5, 5, 0 now receive ordinal ranks 1, 2, 3, 4, 5 by default. Setting AZURE_COSMOS_HYBRID_SEARCH_USE_COMPETITION_RANKING=true selects competition ranks 1, 2, 2, 2, 5 instead, not dense ranks. The internal setting is captured once per query.

Component-score ties use the unsigned numeric document RID in the query-plan sort direction, independent of normalized weights. Final results sort by fused score descending, then numeric document RID descending. The existing RID helper decodes the little-endian document component once per incoming row; encoded RIDs still define deduplication identity. Weights and weight / (60 + rank) remain unchanged.

The score matrix uses the query-plan component count, preserving the existing undefined-score fallback when the first row—or every row—has empty scores. Payloads and reactive paging are retained. No SDK regeneration or Swagger changes are involved.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

The 15 focused offline tests pass with the environment opt-in unset and set to true. Reactor compilation (Java 8 and 21 targets) and configured Checkstyle checks pass; existing Cosmos configuration excludes implementation sources from Checkstyle. Live service tests and SpotBugs were not run. The breaking-change checkbox remains open for review because tie-ranking behavior intentionally changes; no public client API is added.

Port ordinal and opt-in competition ranking with cached numeric document RID tie-breaking and offline regression coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 29c3522f-9887-43c5-bebb-f42ee9ba4d51
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
34 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Derive strict fusion expectations from standalone component queries and numeric document RIDs. Allow only zero-score title ties to vary in non-RRF queries, and use cleanup-compliant test database creation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 29c3522f-9887-43c5-bebb-f42ee9ba4d51
Keep the full-text reference setup and numeric RID tie-break expression on single lines as requested.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 29c3522f-9887-43c5-bebb-f42ee9ba4d51
Restore private ranking helpers and replace implementation-coupled unit tests with public-query integration coverage for ordinal and competition ranks, numeric RID ties, weights, and paging.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 29c3522f-9887-43c5-bebb-f42ee9ba4d51
Move ordinal and competition ranking coverage into HybridSearchQueryTest, reuse its database lifecycle, and remove the obsolete emulator ignore gate.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 29c3522f-9887-43c5-bebb-f42ee9ba4d51
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;

@Ignore("TODO: Ignore these test cases until the public emulator is released.")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Confirming we can remove this ignore?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant