Skip to main content
Version: User Guides (BYOC)

Manage Aliases

In Zilliz Cloud, an alias is a secondary, mutable name for a collection. Using aliases provides a layer of abstraction that allows you to dynamically switch between collections without modifying your application code. This is particularly useful in production environments for seamless data updates, A/B testing, and other operational tasks.

This page demonstrates how to create, list, reassign, and drop collection aliases.

Why Use an Alias

The primary benefit of using an alias is to decouple your client application from a specific, physical collection name.

Imagine you have a live application that queries a collection named prod_data. When you need to update the underlying data, you can perform the update without any service interruption. The workflow would be:

  1. Create a New Collection: Create a new collection, for instance, prod_data_v2.

  2. Prepare Data: Load and index the new data in prod_data_v2.

  3. Switch the Alias: Once the new collection is ready for service, atomically reassign the alias prod_data from the old collection to prod_data_v2.

Your application continues to send requests to the alias prod_data, experiencing zero downtime. This mechanism enables seamless updates and simplifies operations like blue-green deployments for your vector search service.

Key Properties of Aliases:

  • A collection can have multiple aliases.

  • An alias can only point to one collection at a time.

  • When processing a request, Zilliz Cloud first checks if a collection with the provided name exists. If not, it then checks if the name is an alias for a collection.

Create Alias

The following code snippet demonstrates how to create an alias for a collection.

from pymilvus import MilvusClient

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

# 9. Manage aliases
# 9.1. Create aliases
client.create_alias(
collection_name="my_collection_1",
alias="bob"
)

client.create_alias(
collection_name="my_collection_1",
alias="alice"
)

List Aliases

The following code snippet demonstrates the procedure to list the aliases allocated to a specific collection.

# 9.2. List aliases
res = client.list_aliases(
collection_name="my_collection_1"
)

print(res)

# Output
#
# {
# "aliases": [
# "bob",
# "alice"
# ],
# "collection_name": "my_collection_1",
# "db_name": "default"
# }

Describe Alias

The following code snippet describes a specific alias in detail, including the name of the collection to which it has been allocated.

# 9.3. Describe aliases
res = client.describe_alias(
alias="bob"
)

print(res)

# Output
#
# {
# "alias": "bob",
# "collection_name": "my_collection_1",
# "db_name": "default"
# }

Alter Alias

You can reallocate the alias already allocated to a specific collection to another.

# 9.4 Reassign aliases to other collections
client.alter_alias(
collection_name="my_collection_2",
alias="alice"
)

res = client.list_aliases(
collection_name="my_collection_2"
)

print(res)

# Output
#
# {
# "aliases": [
# "alice"
# ],
# "collection_name": "my_collection_2",
# "db_name": "default"
# }

res = client.list_aliases(
collection_name="my_collection_1"
)

print(res)

# Output
#
# {
# "aliases": [
# "bob"
# ],
# "collection_name": "my_collection_1",
# "db_name": "default"
# }

Drop Alias

The following code snippet demonstrates the procedure to drop an alias.

# 9.5 Drop aliases
client.drop_alias(
alias="bob"
)

client.drop_alias(
alias="alice"
)