如何通过Java SDK统计Partition

32 阅读1分钟

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

前提条件

接口定义

Java:

// 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。

Java:

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}}
    }
}

入参描述

参数类型必填默认值描述
nameString-Partition名称

阿里云向量检索服务 DashVector 免费试用进行中,玩转大模型搜索,快来试试吧~ 了解更多信息,请点击:www.aliyun.com/product/ai/…