Get collection statistics

更新时间:
复制 MD 格式

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:

API definition

Collection.stats() -> DashVectorResponse

This method does not have operation-specific request parameters.

Example

Note

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:

ParameterTypeDescriptionExample
codeintStatus code. 0 indicates success. For all status codes, see Status codes.0
messagestrHuman-readable status message.success
request_idstrUnique request identifier, useful for troubleshooting.19215409-ea66-4db9-8764-26ce2eb5bb99
outputCollectionStatsCollection statistics. For the full schema, see CollectionStats.--