All Products
Search
Document Center

Vector Retrieval Service:Query the information about a collection

Last Updated:Apr 11, 2024

This topic describes how to query the status and schema information about an existing collection by using the SDK for Java.

Prerequisites

API definition

// class DashVectorClient

public Response<CollectionMeta> describe(String name);

Example

Note
  1. 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.

  2. 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

Note

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.

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

isSuccess()

Boolean

Specifies whether the operation is successful.

true