milvus-logo
LFAI
Home
  • User Guide

Check Partition Information

This topic describes how to check the information of partitions in Milvus.

Verify if a partition exists

Verify if a partition exists in the specified collection.

from pymilvus import Collection
collection = Collection("book")      # Get an existing collection.
collection.has_partition("novel")
await milvusClient.hasPartition({
  collection_name: "book",
  partition_name: "novel",
});
hasPar, err := milvusClient.HasPartition(
  context.Background(),   // ctx
  "book",                 // CollectionName
  "novel",                // partitionName
)
if err != nil {
  log.Fatal("failed to check the partition:", err.Error())
}
log.Println(hasPar)
R<Boolean> respHasPartition = milvusClient.hasPartition(
  HasPartitionParam.newBuilder()
    .withCollectionName("book")
    .withPartitionName("novel")
    .build()
);
if (respHasPartition.getData() == Boolean.TRUE) {
  System.out.println("Partition exists.");
}
var exists = await milvusClient.GetCollection("book").HasPartitionAsync("novel");
Parameter Description
partition_name Name of the partition to check.
Parameter Description
collection_name Name of the collection to check.
partition_name Name of the partition to check.
Parameter Description
ctx Context to control API invocation process.
CollectionName Name of the collection to check.
partitionName Name of the partition to check.
Parameter Description
collection_name Name of the collection to check.
partition_name Name of the partition to check.

List all partitions

from pymilvus import Collection
collection = Collection("book")      # Get an existing collection.
collection.partitions
await milvusClient.showPartitions({
  collection_name: "book",
});
listPar, err := milvusClient.ShowPartitions(
  context.Background(),   // ctx
  "book",                 // CollectionName
)
if err != nil {
  log.Fatal("failed to list partitions:", err.Error())
}
log.Println(listPar)
R<ShowPartitionsResponse> respShowPartitions = milvusClient.showPartitions(
  ShowPartitionsParam.newBuilder()
          .withCollectionName("book")
          .build()
);
System.out.println(respShowPartitions);
var partitions = await milvusClient.GetCollection("book").ShowPartitionsAsync();
Parameter Description
collection_name Name of the collection to check.
Parameter Description
ctx Context to control API invocation process.
CollectionName Name of the collection to check.
Parameter Description
CollectionName Name of the collection to check.
Parameter Description
collectionName Name of the collection to check.

What’s next

Try Managed Milvus for Free

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

Get Started
Feedback

Was this page helpful?