如何通过Java SDK描述Collection
本文介绍如何通过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"
// }
// }
// }
}
}
浙公网安备 33010602011771号