Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-9153

Clarify sort order for compound indexes on Use Indexes to Sort Query Results

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • None
    • 0.25

    Description

      Submitter's Comment

      The rule of sort order about compound indexes on this page is opposit with https://docs.mongodb.com/manual/tutorial/sort-results-with-indexes/. Latter one says "The sort must specify the same sort direction (i.e.ascending/descending) for all its keys as the index key pattern or specify the reverse sort direction for all its keys as the index key pattern".

      Grooming Description

      Use Indexes to Sort Query Results states the following:

      The sort must specify the same sort direction (i.e.ascending/descending) for all its keys as the index key pattern

      If one is reading quickly, it's easy to miss the as the index key pattern and conclude that when sorting, compound indexes support only {a:1, b:1} indexes, but not {a:1, b:-1} ("the sort must specify the same sort direction for all its keys"). We should rephrase this to better explain what we're actually trying to explain.

      I've taken a stab at doing so my below reply to the original submitter.

      Attachments

        Activity

          People

            allison.moore@mongodb.com Allison Reinheimer Moore
            xgen-internal-docs Docs Collector User (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              7 years, 16 weeks, 2 days ago