< Docs
  • Java


MilvusClient interface. This method checks if a partition exists in the specified collection.

R<Boolean> hasPartition(HasPartitionParam requestParam);


Use the HasPartitionParam.Builder to construct a HasPartitionParam object.

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

Methods of HasPartitionParam.Builder:

Method Description Parameters
withCollectionName(String collectionName) Set the collection name. Collection name cannot be empty or null. collectionName: The target collection name.
withPartitionName(String partitionName) Set the partition name. Partition name cannot be empty or null. partitionName: The target partition name.
build() Construct a HasPartitionParam object. N/A

The can throw the following exceptions:

  • ParamException: error if the parameter is invalid.


This method catches all the exceptions and returns an R<Boolean> 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.Unknown and error message of the exception.

  • If the API succeeds, it returns R.Status.Success.


import io.milvus.param.*;

HasPartitionParam param = HasPartitionParam.newBuilder()
R<Boolean> response = client.hasPartition(param);
if (response.getStatus() != R.Status.Success.getCode()) {

System.out.println("Partition existence: " + response.getData());