-
Type: Question
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.6.5
-
Component/s: Querying
-
None
I'm attempting a descending sort on a subdocument field which is indexed. Without any projection on my query, it appears that my documents use the multikey index's highest value as the sort key. This makes sense to me. However, when I employ $elemMatch to return just one subdocument, per document, the sort key still appears to be the highest value of the multikey index, regardless of whether its subdocument has been projected out. Is there a way to use a multikey indexed field, but respect the $elemMatch?
Example:
{ "_id": "a", "values":[
{"test": 4},
{"test": 1, "keep": true} ] }
{ "_id": "b", "values":[
,
{"test": 2, "keep": true}] }
- duplicates
-
SERVER-13426 weird $sort behavior
- Closed
-
SERVER-19497 Sort is not done on embedded field
- Closed
- is duplicated by
-
SERVER-36338 Multikey sorting of nested array element, selected with $elemMatch
- Closed
- related to
-
SERVER-19402 Change semantics of sorting by array fields in find and aggregate
- Closed