Skip to main content
Version: User Guides (Cloud)

Modify Collection

You can rename a collection or change its settings. This page focuses on how to modify a collection.

Rename Collection

You can rename a collection as follows.

from pymilvus import MilvusClient

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

client.rename_collection(
old_name="my_collection",
new_name="my_new_collection"
)

Set Collection Properties

You can modify collection-level properties after a collection is created.

Supported properties

Property

Description

collection.ttl.seconds

If the data of a collection needs to be deleted after a specific period, consider setting its Time-To-Live (TTL) in seconds. Once the TTL times out, Zilliz Cloud deletes all entities from the collection.

The deletion is asynchronous, indicating that searches and queries are still possible before the deletion is complete.

For details, refer to Set Collection TTL.

mmap.enabled

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.

Zilliz Cloud implements global mmap settings for your clusters. You can change the settings on a specific field or its index.

For details, refer to Use mmap.

partitionkey.isolation

With Partition Key Isolation enabled, Zilliz Cloud groups entities based on the Partition Key value and creates a separate index for each of these groups. Upon receiving a search request, Zilliz Cloud locates the index based on the Partition Key value specified in the filtering condition and restricts the search scope within the entities included in the index, thus avoiding scanning irrelevant entities during the search and greatly enhancing the search performance.

For details, refer to Use Partition Key Isolation.

dynamicfield.enabled

Enables the dynamic field for collections that were created without enabling it. Once enabled, you can insert entities with fields not defined in the original schema. For details, refer to Dynamic Field.

allow_insert_auto_id

Whether to allow a collection to accept user-provided primary key values when AutoID has been enabled for the collection.

  • When set to "true": Inserts, upserts, and bulk imports use the user-provided primary key if present; otherwise, primary key values are auto-generated.

  • When set to "false": User-provided primary key values are rejected or ignored and primary key values are always auto-generated. The default is "false".

timezone

Specifies the default timezone for this collection when handling time-sensitive operations, especially TIMESTAMPTZ fields. Timestamps are stored internally in UTC, and Milvus converts values for display and comparison according to this setting. If set, the collection timezone overrides the database’s default timezone; a query’s timezone parameter can temporarily override both. The value must be a valid IANA time zone identifier (for example, Asia/Shanghai, America/Chicago, or UTC). For details on how to use a TIMESTAMPTZ field, refer to TIMESTAMPTZ Field.

Example 1: Set collection TTL

The following code snippet demonstrates how to set collection TTL.

from pymilvus import MilvusClient

client.alter_collection_properties(
collection_name="my_collection",
properties={"collection.ttl.seconds": 60}
)

Example 2: Enable mmap

The following code snippet demonstrates how to enable mmap.

from pymilvus import MilvusClient

client.alter_collection_properties(
collection_name="my_collection",
properties={"mmap.enabled": True}
)

Example 3: Enable partition key

The following code snippet demonstrates how to enable the partition key.

from pymilvus import MilvusClient

client.alter_collection_properties(
collection_name="my_collection",
properties={"partitionkey.isolation": True}
)

Example 4: Enable dynamic field

The following code snippet demonstrates how to enable the dynamic field.

from pymilvus import MilvusClient

client.alter_collection_properties(
collection_name="my_collection",
properties={"dynamicfield.enabled": True}
)

Example 5: Enable allow_insert_auto_id

The allow_insert_auto_id property allows a collection with AutoID enabled to accept user-provided primary key values during insert, upsert, and bulk import. When set to "true", Zilliz Cloud uses the user-provided primary key value if present; otherwise it auto-generates. Default is "false".

The example below shows how to enable allow_insert_auto_id:

client.alter_collection_properties(
collection_name="my_collection",
properties={"allow_insert_auto_id": "true"}
)
# After enabling, inserts with a PK column will use that PK; otherwise Zilliz Cloud auto-generates.

Example 6: Set collection time zone

You can set a default time zone for your collection using the timezone property. This determines how time-related data is interpreted and displayed for all operations within the collection, including data insertion, querying, and results presentation.

The value of timezone must be a valid IANA time zone identifier, such as Asia/Shanghai, America/Chicago, or UTC. Using an invalid or non-standard value will result in an error when modifying the collection property.

The example below shows how to set the collection time zone to Asia/Shanghai:

client.alter_collection_properties(
collection_name="my_collection",
properties={"timezone": "Asia/Shanghai"}
)

Drop Collection Properties

You can also reset a collection property by dropping it as follows.

client.drop_collection_properties(
collection_name="my_collection",
property_keys=[
"collection.ttl.seconds"
]
)