[DOCS-6409] Comment on: "manual/tutorial/sort-results-with-indexes.txt" Created: 20/Oct/15  Updated: 03/Nov/17  Resolved: 20/Oct/15

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

Type: Bug Priority: Major - P3
Reporter: Docs Collector User (Inactive) Assignee: Kay Kim (Inactive)
Resolution: Done Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

MongoDB Manual 3.0 https://docs.mongodb.org/manual/tutorial/sort-results-with-indexes/

Location: https://docs.mongodb.org/manual/tutorial/sort-results-with-indexes/
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36
Referrer: https://docs.mongodb.org/manual/tutorial/create-indexes-to-support-queries/
Screen Resolution: 1920 x 1080
repo: docs
source: tutorial/sort-results-with-indexes


Participants:
Days since reply: 8 years, 17 weeks, 1 day ago

 Description   

In the section of "Sort and Non-prefix Subset of an Index", the example "db.data.find(

{ b: 3, a: 4 }

).sort(

{ c: 1 }

)" applies the index "

{ a: 1, b: 1, c: 1 }

".

Doesn't order of index make sense in "equity" query in MongoDB? In my understanding, the correct query should be "db.data.find(

{ a: 4, b: 3 }

).sort(

{ c: 1 }

)".



 Comments   
Comment by Kay Kim (Inactive) [ 20/Oct/15 ]

Emailed reporter clarifying
equality conditions
(b equals 3) and (a equals 4) is same as (a equals 4) and (b equals 3)

which means that the query condition + sort on c does indeed match the order of the index prefix

{ a: 1, b: 1, c: 1 }

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