Skip to content

Encode a ranked accumulator's sortBy as one document (2.4.x) - #4585

Open
evanchooly wants to merge 1 commit into
2.4.xfrom
backport-ranked-sortby-2.4
Open

evanchooly wants to merge 1 commit into
2.4.xfrom
backport-ranked-sortby-2.4

Conversation

@evanchooly

Copy link
Copy Markdown
Member

Backport of #4571 to 2.4.x, the same change as #4584.

Problem

$top, $bottom, $topN and $bottomN with more than one sort key encoded sortBy as an array of one-key documents, [{score: -1}, {player: 1}]. The server takes one document whose keys are in priority order, {score: -1, player: 1}, and rejects the array. A single sort key worked.

Change

RankedResultsExpression and NRankedResultsExpression always write sortBy as one document. The sort orders stay Int64, as 2.4 writes them.

Verification

  • New TestRankedSortBy: topN and bottom with two keys encode one ordered document, and the server accepts the pipeline and breaks a tie on the second key.
  • TestTopN, TestBottomN, TestFirstN and TestLastN still pass, 15 tests in all.

$top, $bottom, $topN and $bottomN with more than one sort key wrote
sortBy as an array of one-key documents, which the server rejects; it
takes one document whose keys are in priority order. Backport of #4571.
@evanchooly evanchooly added this to the 2.4.22 milestone Nov 23, 2026

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant