Annotation Interface Sharded


The Sharded annotation provides meta information about the actual distribution of data. The shardKey() is used to distribute documents across shards.
Please see the MongoDB Documentation for more information about requirements and limitations of sharding.
Spring Data adds the shard key to filter queries used for MongoCollection.replaceOne(org.bson.conversions.Bson, Object) operations triggered by save operations on MongoOperations and ReactiveMongoOperations as well as update/upsert operations replacing/upserting a single existing document as long as the given UpdateDefinition holds a full copy of the entity.
All other operations that require the presence of the shard key in the filter query need to provide the information via the Query parameter when invoking the method.
Since:
3.0
Author:
Christoph Strobl, Mark Paluch
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    As of MongoDB 4.2 it is possible to change the shard key using update.
    The sharding strategy to use for distributing data across sharded clusters.
    The shard key determines the distribution of the collection's documents among the cluster's shards.
    Alias for shardKey().