milvus-logo
LFAI
< Docs
  • Python

partition()

This operation gets the specified partition in the current collection.

Request Syntax

partition(
    partition_name: str
)

PARAMETERS:

  • partition_name (str) -

    [REQUIRED]

    The name of the partition to get.

RETURN TYPE:

_Partition _| NoneType

RETURNS:

A Partition object. If the current collection does not have a partition of the specified name, None is returned.

EXCEPTIONS:

  • MilvusException

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

Examples

from pymilvus import Collection, CollectionSchema, FieldSchema, DataType

schema = CollectionSchema([
    FieldSchema("id", DataType.INT64, is_primary=True),
    FieldSchema("vector", DataType.FLOAT_VECTOR, dim=5)
])

# Create a collection
collection = Collection(
    name="test_collection",
    schema=schema
)

# Create a partition
partition = collection.partition(partition_name="test_partition")
Feedback

Was this page helpful?