ListCollectionsV2()

This operation lists all existing collections in a specified database.

public ListCollectionsResp listCollectionsV2(ListCollectionsReq request)

Request Syntax

listCollectionsV2(ListCollectionsReq.builder()
    .databaseName(String databaseName)
    .build()
)

BUILDER METHODS:

  • databaseName(String databaseName)

    The name of the target database. Once specified, this operation returns all collections in the specified database.

RETURN TYPE:

ListCollectionsResp

RETURNS:

A ListCollectionsResp object containing a list of collection names. If there is not any collection, an empty list will be returned.

  • getCollectionNames() (List) -

    A list of strings containing the names of all existing collections.

  • getCollectionInfos() (List) -

    A list of CollectionInfo objects. See CollectionInfo. A CollectionInfo object has the following getters:

    • getCollectionName() (String) -

      The name of a collection.

    • getShardNum() (Integer) -

      The number of shards in the above collection.

EXCEPTIONS:

Example

import io.milvus.v2.client.ConnectConfig;
import io.milvus.v2.client.MilvusClientV2;
import io.milvus.v2.service.collection.request.ListCollectionsReq;
import io.milvus.v2.service.collection.response.ListCollectionsResp;

// 1. Set up a client
ConnectConfig connectConfig = ConnectConfig.builder()
        .uri("http://localhost:19530")
        .token("root:Milvus")
        .build();
        
MilvusClientV2 client = new MilvusClientV2(connectConfig);

// 2. List collections
ListCollectionsReq listCollectionReq = ListCollectionsReq.builder()
    .databaseName("default")
    .build();

ListCollectionsResp listAliasResp = client.listCollectionsV2(listCollectionReq);

Try Managed Milvus for Free

Zilliz Cloud is hassle-free, powered by Milvus and 10x faster.

Get Started
Feedback

Was this page helpful?