本文由簡體中文內容自動轉碼而成。阿里雲不保證此自動轉碼的準確性、完整性及時效性。本文内容請以簡體中文版本為準。

描述Collection

更新時間:2025-03-18 19:36

本文介紹如何通過Java SDK擷取已建立的Collection的狀態和Schema資訊。

前提條件

介面定義

Java
// class DashVectorClient

public Response<CollectionMeta> describe(String name);

使用樣本

說明
  1. 需要使用您的api-key替換樣本中的YOUR_API_KEY、您的Cluster Endpoint替換樣本中的YOUR_CLUSTER_ENDPOINT,代碼才能正常運行。

  2. 本樣本需要參考建立Collection-使用樣本提前建立好名稱為quickstart的Collection。

Java
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", 
        //             "id":"LONG"
        //         },
        //         "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",
    "id":"LONG"
  },
  "partitionStatus":{
    "default":"SERVING"
  }
}

isSuccess()

Boolean

判斷請求是否成功

true

  • 本頁導讀 (1, M)
  • 前提條件
  • 介面定義
  • 使用樣本
  • 入參描述
  • 出參描述
文檔反饋