This topic describes how to query the status and schema information about an existing collection by using the SDK for Java.
Prerequisites
A cluster is created. For more information, see Create a cluster.
An API key is obtained. For more information, see Manage API keys.
The SDK of the latest version is installed. For more information, see Install DashVector SDK.
API definition
// class DashVectorClient
public Response<CollectionMeta> describe(String name);
Example
You need to replace YOUR_API_KEY with your API key and YOUR_CLUSTER_ENDPOINT with the endpoint of your cluster in the sample code for the code to run properly.
You need to create a collection named
quickstart
in advance. For more information, see the "Example" section of the Create a collection topic.
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"
// }
// }
// }
}
}
Request parameters
Parameter | Type | Required | Default value | Description |
name | String | Yes | - | The name of an existing collection. |
Response parameters
A Response<CollectionMeta>
object is returned, which contains the operation result, as described in the following table.
Method | Type | Description | Example |
getCode() | int | The returned status code. For more information, see Status codes. | 0 |
getMessage() | String | The returned message. | success |
getRequestId | String | The unique ID of the request. | 19215409-ea66-4db9-8764-26ce2eb5bb99 |
getOutput() | CollectionMeta | For more information, see CollectionMeta. |
|
isSuccess() | Boolean | Specifies whether the operation is successful. | true |