Get partition statistics
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:
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
// Class: DashVectorCollection
public Response<PartitionStats> statsPartition(String name);Example
Before you run the sample code:
Replace
YOUR_API_KEYwith your API key andYOUR_CLUSTER_ENDPOINTwith the endpoint of your cluster.Create a collection named
quickstart. For more information, see the "Example" section of Create a collection.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
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. | |
isSuccess() | Boolean | Whether the request succeeded. | true |