Get partition statistics

更新时间: 2026-03-11 03:23:38

Query statistics for a partition in a collection, such as the total document count, by using the DashVector SDK for Java.

Prerequisites

Before you begin, make sure that you have:

API definition

// Class: DashVectorCollection

public Response<PartitionStats> statsPartition(String name);

Example

Before you run the sample code:

Note
  1. Replace YOUR_API_KEY with your API key and YOUR_CLUSTER_ENDPOINT with the endpoint of your cluster.

  2. Create a collection named quickstart. For more information, see the "Example" section of Create a collection.

  3. Create a partition named shoes. For more information, see the "Example" section of Create a partition.

import com.aliyun.dashvector.DashVectorClient;
import com.aliyun.dashvector.DashVectorCollection;
import com.aliyun.dashvector.common.DashVectorException;
import com.aliyun.dashvector.models.PartitionStats;
import com.aliyun.dashvector.models.responses.Response;

import java.util.List;

public class Main {
    public static void main(String[] args) throws DashVectorException {
        // Initialize the client with your API key and cluster endpoint
        DashVectorClient client = new DashVectorClient("YOUR_API_KEY", "YOUR_CLUSTER_ENDPOINT");

        // Get the collection
        DashVectorCollection collection = client.get("quickstart");

        // Query partition statistics
        Response<PartitionStats> response = collection.statsPartition("shoes");

        System.out.println(response);
    }
}

Sample response:

{
    "code": 0,
    "message": "Success",
    "requestId": "ebb83c4a-35f7-4128-b1ad-d8e3d9be49a2",
    "output": {
        "totalDocCount": 0
    }
}

Request parameters

Parameter

Type

Required

Default value

Description

name

String

Yes

-

The name of the partition.

Response parameters

Note

The statsPartition method returns a Response<PartitionStats> object with the following methods:

Method

Type

Description

Example

getCode()

int

The status code. For more information, see Status codes.

0

getMessage()

String

The response message.

success

getRequestId()

String

The unique request ID.

19215409-ea66-4db9-8764-26ce2eb5bb99

getOutput()

PartitionStats

The partition statistics. For more information, see PartitionStats.

{"totalDocCount":0}

isSuccess()

Boolean

Whether the request succeeded.

true

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