本文介紹如何通過Java SDK獲取已創建的Collection的狀態和Schema信息。
前提條件
- 已創建Cluster
- 已獲得API-KEY
- 已安裝最新版SDK
接口定義
Java
// class DashVectorClient
public Response<CollectionMeta> describe(String name);
使用示例
説明
-
需要使用您的api-key替換示例中的YOUR_API_KEY、您的Cluster Endpoint替換示例中的YOUR_CLUSTER_ENDPOINT,代碼才能正常運行。
-
本示例需要參考新建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"
// }
// }
// }
}
}