How to partition data using multiple properties in Azure Cosmos DB? I tried to check in the Azure documentation, but couldn't find a solution.
Can anyone please help me out here?
I want to partition data using multiple columns/properties. Eg UserId and ProductId. Is it possible to do so?
Currently it is not possible to partition a collection on multiple properties. You could create a composite key (eg UserProductId
) that stores both user id and product id and use that for partitioning of data.
I'm looking at doing this now, and just wanted to share this doco that I came across from Microsoft which talks about this practice:
https://docs.microsoft.com/en-us/azure/cosmos-db/sql/synthetic-partition-keys
Basically the answer, as the above Accepted Answer confirmed a few years ago, is "use a synthetic partition", and this document goes into more detail about this solution.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.