Get partition statistics

更新时间: 2026-03-10 22:23:25

Retrieve statistics for a partition in a collection, such as the total document count. Use this to monitor data distribution across partitions or verify document insertion.

Prerequisites

Before you begin, ensure that you have:

API signature

Collection.stats_partition(name: str) -> DashVectorResponse

Request parameters

ParameterTypeRequiredDescription
namestrYesThe name of the partition to query

Response

A DashVectorResponse object is returned with the following fields:

FieldTypeDescriptionExample
codeintStatus code. For more information, see Status codes.0
messagestrStatus messagesuccess
request_idstrUnique request identifier19215409-ea66-4db9-8764-26ce2eb5bb99
outputPartitionStatsPartition statistics, including total_doc_count

Example

This example retrieves the document count for a partition named shoes in the quickstart collection.

Note

This example requires a collection named quickstart and a partition named shoes. To set these up, see the examples in Create a collection and Create a partition.

Replace <your-api-key> and <your-cluster-endpoint> with your actual API key and cluster endpoint.

import dashvector

# 1. Initialize the client
client = dashvector.Client(
    api_key='<your-api-key>',
    endpoint='<your-cluster-endpoint>'
)

# 2. Get the collection
collection = client.get(name='quickstart')

# 3. Query partition statistics
ret = collection.stats_partition('shoes')
print(ret)

Sample response:

{
    "code": 0,
    "message": "",
    "requests_id": "330a2bcb-e4a7-4fc6-a711-2fe5f8a24e8c",
    "output": {
        "total_doc_count": 0
    }
}

A total_doc_count of 0 indicates that the partition exists but contains no documents. After you insert documents into this partition, total_doc_count returns the total number of stored documents.

上一篇: List partitions 下一篇: Delete a partition