[DOCS-9153] Clarify sort order for compound indexes on Use Indexes to Sort Query Results Created: 17/Oct/16  Updated: 24/Oct/16  Resolved: 24/Oct/16

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Docs Collector User (Inactive) Assignee: Allison Reinheimer Moore
Resolution: Done Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Location: https://docs.mongodb.com/manual/core/index-compound/
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0
Referrer: https://docs.mongodb.com/manual/core/index-single/
Screen Resolution: 1920 x 1080


Participants:
Days since reply: 7 years, 16 weeks, 2 days ago
Story Points: 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.



 Comments   
Comment by Githook User [ 24/Oct/16 ]

Author:

{u'username': u'schmalliso', u'name': u'Allison Moore', u'email': u'allison.moore@10gen.com'}

Message: DOCS-9153: rephrases sort order for compound indexes
Branch: v3.2
https://github.com/mongodb/docs/commit/c05c99021c2f5835c2b919485de99bcff9efb2aa

Comment by Githook User [ 24/Oct/16 ]

Author:

{u'username': u'schmalliso', u'name': u'Allison Moore', u'email': u'allison.moore@10gen.com'}

Message: DOCS-9153: rephrases sort order for compound indexes
Branch: master
https://github.com/mongodb/docs/commit/3b1bb860c67aa48d69ffd036d32f37def38073c7

Comment by Allison Reinheimer Moore [ 17/Oct/16 ]

Hello!

Thanks so much for bringing this to our attention! The wording on the Use Indexes to Sort Query Results page that you quote is, indeed, confusing. We'll be sure to update that.

What we're trying to say is that a compound index with pattern {a:1, b:-1} can support sorting on the same sort direction: {a:1, b:-1}, and the reverse direction: {a:-1, b:1}, but could not support sorting on {a:1, b:1} or {a:-1, b:-1}.

So, in short, what it says on the Compound Indexes page is correct and we've explained the concept poorly on the Use Indexes to Sort Query Results page. We'll update the page to clarify.

Thanks so much!
Allison

Generated at Thu Feb 08 07:57:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.