milvus-logo
LFAI
< Docs
  • Java

describeCollection()

A MilvusClient interface. This method shows the details of a collection, including collection name, schema, and more.

R<DescribeCollectionResponse> describeCollection(DescribeCollectionParam requestParam);

DescribeCollectionParam

Use the DescribeCollectionParam.Builder to construct a DescribeCollectionParam object.

import io.milvus.param.DescribeCollectionParam;
DescribeCollectionParam.Builder builder = DescribeCollectionParam.newBuilder();

Methods of DescribeCollectionParam.Builder:

MethodDescriptionParameters
withCollectionName(String collectionName)Sets the collection name. The collection name cannot be empty or null.collectionName: The name of the collection to show details of.
build()Constructs a DescribeCollectionParam object.N/A

The DescribeCollectionParam.Builder.build() can throw the following exceptions:

  • ParamException: error if the parameter is invalid.

Returns

This method catches all the exceptions and returns an R<DescribeCollectionResponse> object.

  • If the API fails on the server side, it returns the error code and message from the server.

  • If the API fails by RPC exception, it returns R.Status.Unknow and the error message of the exception.

  • If the API succeeds, it returns a valid DescribeCollectionResponse held by the R template. You can use DescCollResponseWrapper to get the information.

DescCollResponseWrapper

A tool class to encapsulate the DescribeCollectionResponse.

import io.milvus.response.DescCollResponseWrapper;
DescCollResponseWrapper wrapper = new DescCollResponseWrapper(descCollectionResponse);

Methods of DescCollResponseWrapper:

MethodDescriptionParametersReturns
getCollectionName()Gets the name of the collection.N/AString
getCollectionDescription()Gets the description of the collection.N/AString
getCollectionID()Gets the ID of the collection.N/Along
getShardNumber()Gets the number of shards of the collection.N/AInt
getCreatedUtcTimestamp()Gets the UTC timestamp that indicates when the collection is created.N/Along
getAliases()Gets the alias of the collection.N/AList
getFields()Gets all field schemas in the collection.N/AList<FieldType>
getFieldByName(String fieldName)Gets a field schema by its field name.fieldName: a field nameFieldType
isDynamicFieldEnabled()Get whether dynamic fields are allowed in the collection.N/Aboolean
getPartitionKeyField()Get the field on which partition key is enabled.N/AFieldType

Example

import io.milvus.param.*;
import io.milvus.response.DescCollResponseWrapper;
import io.milvus.grpc.DescribeCollectionResponse;

DescribeCollectionParam param = DescribeCollectionParam.newBuilder()
        .withCollectionName(collectionName)
        .build();
R<DescribeCollectionResponse> response = client.describeCollection(param);
if (response.getStatus() != R.Status.Success.getCode()) {
    System.out.println(response.getMessage());
}

DescCollResponseWrapper wrapper = new DescCollResponseWrapper(response.getData());
System.out.println("Collection ID: " + wrapper.getCollectionID());
Feedback

Was this page helpful?