文档

统计Partition

更新时间:

本文介绍如何通过Java SDK获取Collection中一个已存在的Partition的统计信息,如Doc数等。

前提条件

接口定义

// class DashVectorCollection

public Response<PartitionStats> statsPartition(String name);

使用示例

说明
  1. 需要使用您的api-key替换示例中的YOUR_API_KEY、您的Cluster Endpoint替换示例中的YOUR_CLUSTER_ENDPOINT,代码才能正常运行。

  2. 本示例需要参考新建Collection提前创建好名称为quickstart的Collection。

  3. 本示例需要参考新建Partition提前创建好名称为shoes的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 {
        DashVectorClient client = new DashVectorClient("YOUR_API_KEY", "YOUR_CLUSTER_ENDPOINT");
        DashVectorCollection collection = client.get("quickstart");
      
        Response<PartitionStats> response = collection.statsPartition("shoes");
    
        System.out.println(response);
        // example output:
        // {"code":0,"message":"Success","requestId":"ebb83c4a-35f7-4128-b1ad-d8e3d9be49a2","output":{"totalDocCount":0}}
    }
}

入参描述

参数

类型

必填

默认值

描述

name

String

-

Partition名称

出参描述

说明

返回结果为Response<PartitionStats>对象,Response<PartitionStats>对象中可获取本次操作结果信息,如下表所示。

方法

类型

描述

示例

getCode()

int

返回值,参考返回状态码说明

0

getMessage()

String

返回消息

success

getRequestId()

String

请求唯一id

19215409-ea66-4db9-8764-26ce2eb5bb99

getOutput()

PartitionStats

参考PartitionStats

{"totalDocCount":0}

isSuccess()

Boolean

判断请求是否成功

true