-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Sharding NYC
-
Fully Compatible
-
Sharding NYC 2023-10-30, Cluster Scalability 2023-11-13
Shard key fields must be ascending, with at most one hashed field. Descending fields are not allowed (SERVER-8129)
When you attempt to create one with a descending field, the error message is confusing
[direct: mongos] test> sh.shardCollection("test.foo", {a:-1}) MongoServerError: Shard key { a: -1 } can contain at most one 'hashed' field, and/or multiple numerical fields set to a value of 1. Failed to parse field a
Can we reword this to be something like
Shard key XXXX can contain at most one 'hashed' field, and/or multiple fields with a value of 1 (ascending). Failed to parse field a
Or modify the code to have different error blocks for "more than one hashed field" and "invalid field value" to make the error message more tailored.