Skip to main content
Go to documentation:
⌘U
Weaviate Database

Develop AI applications using Weaviate's APIs and tools

Deploy

Deploy, configure, and maintain Weaviate Database

Weaviate Agents

Build and deploy intelligent agents with Weaviate

Weaviate Cloud

Manage and scale Weaviate in the cloud

Additional resources

Integrations
Contributor guide
Events & Workshops
Weaviate Academy

Need help?

Weaviate LogoAsk AI Assistant⌘K
Community Forum

Collection aliases

Added in v1.32

Collection aliases allow you to create alternative names for your collections. This is useful for migrating between collections without downtime, A/B testing, or providing more convenient names for collections. An alias acts as a reference to a collection - when you query and manage objects using an alias name, Weaviate automatically routes the request to the target collection.

Collection alias usage

Weaviate automatically routes alias requests to the target collection for object-related operations. You can use aliases wherever collection names are required for:

Create an alias

To create an alias, specify the alias name and the target collection it should point to.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
# Create a collection first
client.collections.create(
name="Articles",
vector_config=wvc.config.Configure.Vectors.self_provided(),
properties=[
wvc.config.Property(name="title", data_type=wvc.config.DataType.TEXT),
wvc.config.Property(name="content", data_type=wvc.config.DataType.TEXT),
],
)

# Create an alias pointing to the collection
client.alias.create(alias_name="ArticlesAlias", target_collection="Articles")
note
  • An alias name must be unique and cannot match any existing collection or alias name
  • Multiple aliases can point to the same collection
  • Aliases can only be used instead of collection names in object-related operations (managing objects and querying)

List all aliases

Retrieve all aliases in your Weaviate instance.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
# Get all aliases in the instance
all_aliases = client.alias.list_all()

for alias_name, alias_info in all_aliases.items():
print(f"Alias: {alias_info.alias} -> Collection: {alias_info.collection}")

List aliases for a specific collection

Get all aliases that point to a specific collection.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
# Get all aliases pointing to a specific collection
collection_aliases = client.alias.list_all(collection="Articles")

for alias_name, alias_info in collection_aliases.items():
print(f"Alias pointing to Articles: {alias_info.alias}")

Get alias details

Retrieve information about a specific alias.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
# Get information about a specific alias
alias_info = client.alias.get(alias_name="ArticlesAlias")

if alias_info:
print(f"Alias: {alias_info.alias}")
print(f"Target collection: {alias_info.collection}")

Update an alias

Change the target collection that an alias points to. This operation is atomic and provides instant switching between collections.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
# Create a new collection for migration
client.collections.create(
name="ArticlesV2",
vector_config=wvc.config.Configure.Vectors.self_provided(),
properties=[
wvc.config.Property(name="title", data_type=wvc.config.DataType.TEXT),
wvc.config.Property(name="content", data_type=wvc.config.DataType.TEXT),
wvc.config.Property(
name="author", data_type=wvc.config.DataType.TEXT
), # New field
],
)

# Update the alias to point to the new collection
success = client.alias.update(
alias_name="ArticlesAlias", new_target_collection="ArticlesV2"
)

if success:
print("Alias updated successfully")
Use case: Zero-downtime migration

Updating an alias is particularly useful for migrations:

  1. Create a new collection with updated collection definition
  2. Import data into the new collection
  3. Update the alias to point to the new collection
  4. Continue to use the alias - all queries to it are now directed to the new collection

For a code example on how to perform migrations, visit the Tutorial: Migrating collections with aliases

Delete an alias

Remove an alias. This only deletes the alias pointer, not the underlying collection.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
# Delete an alias (the underlying collection remains)
client.alias.delete(alias_name="ArticlesAlias")
note
  • Deleting a collection does not automatically delete aliases pointing to it

Using aliases in operations

Once created, aliases can be used instead of collection names in all object-related operations, like data import and querying.

py docs  API docs
More infoCode snippets in the documentation reflect the latest client library and Weaviate Database version. Check the Release notes for specific versions.

If a snippet doesn't work or you have feedback, please open a GitHub issue.
# Ensure the Articles collection exists (it might have been deleted in previous examples)

client.collections.create(
name="Articles",
vector_config=wvc.config.Configure.Vectors.self_provided(),
properties=[
wvc.config.Property(name="title", data_type=wvc.config.DataType.TEXT),
wvc.config.Property(name="content", data_type=wvc.config.DataType.TEXT),
],
)
# Use the alias just like a collection name
articles = client.collections.use("ArticlesAlias")

# Insert data using the alias
articles.data.insert(
{
"title": "Using Aliases in Weaviate",
"content": "Aliases make collection management easier...",
}
)

# Query using the alias
results = articles.query.fetch_objects(limit=5)

for obj in results.objects:
print(f"Found: {obj.properties['title']}")

Further resources

Questions and feedback

If you have any questions or feedback, let us know in the user forum.