文档

描述Collection

更新时间:

本文介绍如何通过Java SDK获取已创建的Collection的状态和Schema信息。

前提条件

接口定义

// class DashVectorClient

public Response<CollectionMeta> describe(String name);

使用示例

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

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

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

public class Main {
    public static void main(String[] args) throws DashVectorException {
        DashVectorClient client = new DashVectorClient("YOUR_API_KEY", "YOUR_CLUSTER_ENDPOINT");

        Response<CollectionMeta> response = client.describe("quickstart");

        System.out.println(response);
        // example output:
        // {
        //     "code":0,
        //     "message":"",
        //     "requestId":"cb468965-d86b-405a-87a4-a596e61c1240",
        //     "output":{
        //         "name":"quickstart",
        //         "dimension":4,
        //         "dataType":"FLOAT",
        //         "metric":"dotproduct",
        //         "status":"SERVING",
        //         "fieldsSchema":{
        //             "name":"STRING",
        //             "weight":"FLOAT",
        //             "age":"INT"
        //         },
        //         "partitionStatus":{
        //             "default":"SERVING"
        //         }
        //     }
        // }
    }
}

入参描述

参数

类型

必填

默认值

说明

name

String

-

已创建集合的名称

出参描述

说明

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

字段

类型

描述

示例

getCode()

int

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

0

getMessage()

String

返回消息

success

getRequestId

String

请求唯一id

19215409-ea66-4db9-8764-26ce2eb5bb99

getOutput()

CollectionMeta

参考CollectionMeta

{
  "name":"quickstart",
  "dimension":4,
  "dataType":"FLOAT",
  "metric":"dotproduct",
  "status":"SERVING",
  "fieldsSchema":{
    "name":"STRING",
    "weight":"FLOAT",
    "age":"INT"
  },
  "partitionStatus":{
    "default":"SERVING"
  }
}

isSuccess()

Boolean

判断请求是否成功

true

  • 本页导读 (0)
文档反馈