The error "couldn't find valid index for shard key" and code "96" indicates that the sharding process has failed because the sharded collection does not have a valid index for its shard key. This error typically occurs when attempting to shard a collection that does not have a unique index on the shard key field.
To resolve this issue, you must create an index on the shard key field before attempting to shard the collection. Additionally, the shard key field should be a unique identifier for each document in the collection to ensure even distribution of data across shards.
Asked: 2023-06-07 15:37:11 +0000
Seen: 8 times
Last updated: Jun 07 '23