Get all partition keys in an Azure Cosmos DB gallery

I recently started using Azure Cosmos DB in our project. For reporting purposes, we need to get all the section keys in the collection. I couldn't find a suitable API to achieve it.

+5


source to share


2 answers


UPDATE: As per Brian in the comments below, DISTINCT

now supported. Try something like:

SELECT DISTINCT c.partitionKey FROM c

      

Previous answer ...



The only way to get the actual values โ€‹โ€‹of the keys of the sections is to make a unique aggregate on this field. However, there is a relatively simple way to get the key ranges of a section. It is not directly supported in any of the SDKs as far as I know, but you can directly hit the REST endpoint in https://{your endpoint domain}.documents.azure.com/dbs/{your collection uri fragment}/pkranges

to override the ranges for the section keys for each section. Please note: the bottom side is included, so you can use it to make your own fan.

Warning. There is a small chance that pkranges could change between the time they were fetched and the time you intend to do something with them. Either take that subtle risk or the code around it.

+3


source


This functionality is currently not available. However, there is a feedback element here



0


source







All Articles