@Override
    public Mono<Void> shard(MongoEntity<?> entity) {
        BsonDocument shardKey = entity.getShardKeyBson();
        if (shardKey == null) {
            return Mono.empty();
        }
        String namespace = getNamespace(entity.collectionName());
        Document command = new Document("shardCollection", namespace).append("key", shardKey);
        Mono<Document> shardCollection = Mono.from(context.getAdminDatabase()
                .runCommand(command))
                .onErrorMap(t -> new RuntimeException(
                        "Failed to shard the collection \""
                                + namespace
                                + "\" with the shard key: "
                                + shardKey.toJson(),
                        t))
                .doOnSuccess(ignored -> LOGGER.info(
                        "Sharded the collection \"{}\" with the shard key: {}",
                        namespace,
                        shardKey.toJson()));
        return shardCollection.then();
    }
apply the shard key to the filter so that mongos know to which MongoDB the command needs to
be sent for better performance
turms-server-common/src/main/java/im/turms/server/common/storage/mongo/operation/TurmsMongoOperations.java