-
Type:
Bug
-
Resolution: Duplicate
-
Priority:
Major - P3
-
None
-
Affects Version/s: 2.4.5
-
Component/s: Sharding
-
None
-
Environment:RHEL 5.8
-
ALL
-
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
We've encountered an error migrating to sharded environment.
It appear there is a difference between querying mongod and mongos as shown below:
> c = db.test.find(
,
{f:0}).sort(
{"f":1})
{ "_id" : ObjectId("525be8c1513f4b195eaa8d00"), "title" : "shay" }mongos> c = db.test.find(
{title: "shay"},
{f:0}).sort(
{"f":1})
error: {
"$err" : "have to have sort key in projection and removing it",
"code" : 13431
}
I understand (now) that it is not possible to exclude a field from a query and sort on it through mongos (that gets the documents without the fields and needs to sort upon them).
However, as development was done a single mongod, we've encountered this error only now when deploying at scale. Now this requires changing our application code accordingly.
One of the reasons we chose MongoDB was the "scale without affecting existing data or application code" paradigm. Therefore I believe the same behavior of mongos' must be enforced on the shards as well to allow that.
Thanks
Shay