[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/ |
||
| Participants: | |
| Days since reply: | 7 years, 16 weeks, 2 days ago |
| Story Points: | 0.25 |
| Description |
Submitter's CommentThe 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 DescriptionUse Indexes to Sort Query Results states the following:
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: |
| 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: |
| 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! |