When mongos is asked to perform on a sort on a field that is implicitly projected out (e.g. by an inclusion of another field), mongos does not strip out the field as expected.
Reproduce with the following ("collection" can be either sharded or unsharded):
mongos> db.collection.insert({_id:9, a:"hello"}) mongos> db.collection.find({},{_id:1}) { "_id" : 9 } mongos> db.collection.find({},{_id:1}).sort({a:1}) { "_id" : 9, "a" : "hello" }
It is not expected that "a" is returned in the results for the sorted query above. Running the same query when connected directly to the shard returns the correct results:
> db.collection.find({},{_id:1}) { "_id" : 9 } > db.collection.find({},{_id:1}).sort({a:1}) { "_id" : 9 }
- duplicates
-
SERVER-19355 Support skip, limit, and projection in new find/getMore commands path on mongos
- Closed
- related to
-
SERVER-10831 Sorting doesn't work if sort key excluded in projection with a sharded collections
- Closed