Collection.stats() returns the current state of a collection, including document count, index completeness, and document distribution across partitions. This topic uses the SDK for Python.
Prerequisites
Before you begin, make sure that you have:
A DashVector cluster. For more information, see Create a cluster
An API key. For more information, see Manage API keys
The latest version of the DashVector SDK. For more information, see Install DashVector SDK
API definition
Collection.stats() -> DashVectorResponseThis method does not have operation-specific request parameters.
Example
Before running this example, replace YOUR_API_KEY with your API key and YOUR_CLUSTER_ENDPOINT with the endpoint of your cluster. You also need a collection named quickstart. For details, see the "Example" section in Create a collection.
import dashvector
client = dashvector.Client(
api_key='YOUR_API_KEY',
endpoint='YOUR_CLUSTER_ENDPOINT'
)
collection = client.get(name='quickstart')
ret = collection.stats()
print(ret)Example output
{
"request_id": "14448bcb-c9a3-49a8-9152-0de3990bce59",
"code": 0,
"message": "Success",
"output": {
"total_doc_count": "26",
"index_completeness": 1.0,
"partitions": {
"default": {
"total_doc_count": "26"
}
}
}
}Response parameters
Collection.stats() returns a DashVectorResponse object with the following fields:
| Parameter | Type | Description | Example |
|---|---|---|---|
code | int | Status code. 0 indicates success. For all status codes, see Status codes. | 0 |
message | str | Human-readable status message. | success |
request_id | str | Unique request identifier, useful for troubleshooting. | 19215409-ea66-4db9-8764-26ce2eb5bb99 |
output | CollectionStats | Collection statistics. For the full schema, see CollectionStats. | -- |