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

sort order on multi key index queries not as expected

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.6.8, 4.0.4
    • Labels:
      None
    • ALL
    • Hide

      Please run the attached script. It returns the documents in reverse order to what is expected.

      Show
      Please run the attached script. It returns the documents in reverse order to what is expected.

      I have a system which stores documents that have an array valued field which contains pairs of metric names and values. I also have a compound index on this field which should enable querying for all documents containing a metric with a given name and returning them sorted by metric value. However, it looks like sorting works correctly only of the first element of the array.

      I'm pretty sure it did work as expected in previous MongoDB versions, but I'm not sure when it stopped working.

      I did work around the issue using the aggregation framework to get the correct sorting, but this has slowed down queries a lot.

        1. test.js
          0.4 kB

            Assignee:
            daniel.hatcher@mongodb.com Danny Hatcher (Inactive)
            Reporter:
            skaes Stefan Kaes
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: