This topic describes how to query statistical information about an existing partition in a collection, such as the number of documents, by using the SDK for Python.
Prerequisites
A cluster is created. For more information, see Create a cluster.
An API key is obtained. For more information, see Manage API keys.
The SDK of the latest version is installed. For more information, see Install DashVector SDK.
API definition
Collection.stats_partition(name: str) -> DashVectorResponseExample
You need to replace YOUR_API_KEY with your API key and YOUR_CLUSTER_ENDPOINT with the endpoint of your cluster in the sample code for the code to run properly.
You need to create a collection named
quickstartin advance. For more information, see the "Example" section of the Create a collection topic.You must create a partition named
shoesin advance. For more information, see the "Example" section of the Create a partition topic.
import dashvector
client = dashvector.Client(
api_key='YOUR_API_KEY',
endpoint='YOUR_CLUSTER_ENDPOINT'
)
collection = client.get(name='quickstart')
ret = collection.stats_partition('shoes')
print(ret)
# {
# "code":0,
# "message":"",
# "requests_id":"330a2bcb-e4a7-4fc6-a711-2fe5f8a24e8c",
# "output":{
# "total_doc_count":0
# }
# }Request parameters
Parameter | Type | Default value | Description |
name | str | - | The name of the partition. |
Response parameters
A DashVectorResponse object is returned, which contains the operation result, as described in the following table.
Parameter | Type | Description | Example |
code | int | The returned status code. For more information, see Status codes. | 0 |
message | str | The returned message. | success |
request_id | str | The unique ID of the request. | 19215409-ea66-4db9-8764-26ce2eb5bb99 |
output | PartitionStats | For more information, see PartitionStats. |