List partitions

Updated at:

List all partitions in a DashVector collection using the Python SDK.

Partitions organize vectors within a collection into logical groups. Use list_partitions() to retrieve the names of all partitions in a collection. All partitions are returned in a single call.

Prerequisites

API reference

Collection.list_partitions() -> DashVectorResponse

This method takes no request parameters.

Example

Note

Replace the following placeholders with your actual values before you run the code.

PlaceholderDescriptionExample
<your-api-key>API key for your clusterLTAI5tXxx
<your-cluster-endpoint>Endpoint of your clustervrs-xxx.dashvector.region.aliyuncs.com

This example uses a collection named quickstart. To create one, see the "Example" section of Create a collection.

import dashvector

client = dashvector.Client(
    api_key='<your-api-key>',
    endpoint='<your-cluster-endpoint>'
)
collection = client.get(name='quickstart')

# List all partitions in the collection
partitions = collection.list_partitions()

if partitions:
    for pt in partitions:
        print(pt)
else:
    print(partitions)  # Print the error details

Expected output:

default
shoes

Additional operations

The returned partitions object also supports length checks and membership tests:

# Number of partitions
print(len(partitions))

# Check if a specific partition exists
print('quickstart' in partitions)

Expected output:

2
True

Response parameters

list_partitions() returns a DashVectorResponse object with the following fields:

ParameterTypeDescriptionExample
codeintStatus code. See Status codes.0
messagestrResponse message.success
request_idstrUnique request ID.19215409-ea66-4db9-8764-26ce2eb5bb99
outputlist[str]Names of all partitions in the collection.['shoes', 'default']

What's next