Skip to main content
Version: User Guides (Cloud)

Alter Collection Field

You can alter the properties of a collection field to change column constraints or enforce stricter data integrity rules.

📘Notes
  • Each collection consists of only one primary field. Once set during collection creation, you cannot change the primary field or alter its properties.

  • Each collection can have only one partition key. Once set during collection creation, you cannot change the partition key.

Alter VarChar field

A VarChar field has a property named max_length, which constrains the maximum number of characters the field values can contain. You can change the max_length property.

The following example assumes the collection has a VarChar field named varchar and sets its max_length property.

from pymilvus import MilvusClient

client = MilvusClient(
uri="YOUR_CLUSTER_ENDPOINT",
token="YOUR_CLUSTER_TOKEN"
)

client.alter_collection_field(
collection_name="my_collection",
field_name="varchar",
field_params={
"max_length": 1024
}
)

Alter ARRAY field

An array field has two properties, namely element_type and max_capacity. The former determines the data type of the elements in an array, while the latter constrains the maximum number of elements in the array. You can change the max_capacity property only.

The following example assumes the collection has an array field named array and sets its max_capacity property.

client.alter_collection_field(
collection_name="my_collection",
field_name="array",
field_params={
"max_capacity": 64
}
)

Alter field-level mmap settings

Memory mapping (Mmap) enables direct memory access to large files on disk, allowing Zilliz Cloud to store indexes and data in both memory and hard drives. This approach helps optimize data placement policy based on access frequency, expanding storage capacity for collections without impacting search performance.

The following example assumes the collection has a field named doc_chunk and sets its mmap_enabled property.

client.alter_collection_field(
collection="my_collection",
field_name="doc_chunk",
properties={"mmap.enabled": True}
)