microsoft / spring-data-cosmosdb

Access data with Azure Cosmos DB
MIT License
94 stars 64 forks source link

Composite Partition Key #460

Open mohanajuhi166 opened 4 years ago

mohanajuhi166 commented 4 years ago

Currently ,I have a document structure which requires a composite Partition key of the following structure tableName:"", DatabaseName:"", Platform:"", Databasetype:"" I tried creating an entity and setting that to a Partition key but it didn't work.

Is there a provision for a composite partition key ?

2) Do we need to explicitly close the cosmosdb connection if we are using Spring-data-cosmosdb. How can we monitor how many database connections are open/close ?

Thank you.

kushagraThapar commented 4 years ago

@mohanajuhi166 : composite partition key is not supported by Cosmos DB.

Regarding closing cosmosdb connection, you do not need to explicitly close cosmos db connection. Make sure to close cosmosdb client when you are done with your application.

CosmosDB connections are auto closed if any of them are idle for a particular time period (depends on Connection mode).

Jerify02 commented 4 years ago

Hi @kushagraThapar , the cosmos doc has a chapter about synthetic-partition-keys, https://docs.microsoft.com/en-us/azure/cosmos-db/synthetic-partition-keys but I can't find how to create a synthetic partition key.

linux-code commented 4 years ago

@Jerify02 synthetic partition key is something you have to generate at application layer- let's say- in container, we have defined partitionKey as /partitionKey.

and you want to generate partitionKey using more than one fields value- String pKey = field1 + "-" + field2 + "-" +.....+"-"+ fieldN (assuming- hyphen delimiter here).

set partitionKey value as pKey and then save the document or findById(id, partitionKey).

kushagraThapar commented 4 years ago

@linux-code thanks for helping here. @Jerify02 - are you still facing this issue ?