This topic describes how to query statistical information about an existing collection, such as the number of documents, by using the HTTP API.
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.
Method and URL
GET https://{Endpoint}/v1/collections/{CollectionName}/stats
Example
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
quickstart
in advance. For more information, see the "Example" section of the Create a collection topic.
curl -H 'dashvector-auth-token: YOUR_API_KEY' \
https://YOUR_CLUSTER_ENDPOINT/v1/collections/quickstart/stats
# 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"
# }
# }
# }
# }
Request parameters
Parameter | Location | Type | Required | Description |
{Endpoint} | path | str | Yes | The endpoint of the cluster. You can view the endpoint on the cluster details page in the console. |
{CollectionName} | path | str | Yes | The name of the existing collection. |
dashvector-auth-token | header | str | Yes | The API key. |
Response parameters
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 | object | For more information, see CollectionStats. |