Skip to main content
Version: User Guides (BYOC)

Manage Aliases

Zilliz Cloud provides alias management capabilities. This page demonstrates the procedures to create, list, alter, and drop aliases.

Overview

You can create aliases for your collections. A collection can have several aliases, but collections cannot share an alias.

Upon receiving a request against a collection, Zilliz Cloud locates the collection based on the provided name. If the collection by the provided name does not exist, Zilliz Cloud continues locating the provided name as an alias. You can use collection aliases to adapt your code to different scenarios.

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="customized_setup_2",
alias="bob"
)

client.create_alias(
collection_name="customized_setup_2",
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="customized_setup_2"
)

print(res)

# Output
#
# {
# "aliases": [
# "bob",
# "alice"
# ],
# "collection_name": "customized_setup_2",
# "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": "customized_setup_2",
# "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="customized_setup_1",
alias="alice"
)

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

print(res)

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

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

print(res)

# Output
#
# {
# "aliases": [
# "bob"
# ],
# "collection_name": "customized_setup_2",
# "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"
)