メインコンテンツまでスキップ

listCollections()

Addedv2.4.xModifiedv2.6.x

This operation lists all existing collections.

public ListCollectionsResp listCollections()

Request Syntax

listCollections()

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.

PARAMETERS:

  • collectionNames (List<String>)

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

  • collectionInfos (List<CollectionInfo>)

    A list of CollectionInfo objects. A CollectionInfo object has the following fields:

    • collectionName (String)

      The name of a collection.

    • shardNum (Integer)

      The number of shards in the above collection.

EXCEPTIONS:

  • MilvusClientExceptions

    This exception will be raised when any error occurs during this operation.

Example

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

// 1. Set up a client
ConnectConfig connectConfig = ConnectConfig.builder()
.uri("YOUR_CLUSTER_ENDPOINT")
.token("YOUR_CLUSTER_TOKEN")
.build();

MilvusClientV2 client = new MilvusClientV2(connectConfig);

// 2. List collections
ListCollectionsResp listAliasResp = client.listCollections();