Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-60781

$topN results not returned in order according to sort spec

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.2.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • QE 2021-11-01

      With the current implementation $bottomN returns results in the order you would get by using a $sort stage with the same sort spec, but $topN does not. $topN currently returns results in the order opposite of the sort spec, e.g. {a: 1} currently returns the largest $a first whereas a $sort stage would return the smallest $a first.

      Pending on going discussion of result ordering in the Exact Top N Accumulator project, we should update AccumulatorTopBottomN to reflect that decision and change all the tests.

            Assignee:
            mihai.andrei@mongodb.com Mihai Andrei
            Reporter:
            mickey.winters@mongodb.com Mickey Winters
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: