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

Academy
Integrations
Contributor guide
Events & Workshops

Need help?

Weaviate LogoAsk AI Assistant⌘K
Community Forum

Collection aliases

Technical preview

Collection aliases were added in v1.32 as a technical preview.

This means that the feature is still under development and may change in future releases, including potential breaking changes. We do not recommend using this feature in production environments at this time.

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

Create an alias

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

# 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="ArticlesProd", 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 be used instead of collection names in most operations (except when deleting collections)

List all aliases

Retrieve all aliases in your Weaviate instance.

# Get all aliases in the instance
all_aliases = client.alias.list_all()

# Filter to show only aliases from this example
for alias_name, alias_info in all_aliases.items():
if alias_info.collection in ["Articles", "ArticlesV2"]:
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.

# 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.

# Get information about a specific alias
alias_info = client.alias.get(alias_name="ArticlesProd")

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.

# 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="ArticlesProd", 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 Starter guide: Managing collections

Delete an alias

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

# Delete an alias (the underlying collection remains)
client.alias.delete(alias_name="ArticlesProd")
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 most operations (except when deleting collections):

# 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),
],
)
# Create an alias for easier access
client.alias.create(alias_name="MyArticles", target_collection="Articles")

# Use the alias just like a collection name
articles = client.collections.get("MyArticles")

# 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']}")

# Add a new property using the alias
articles.config.add_property(
wvc.config.Property(name="author", data_type=wvc.config.DataType.TEXT)
)

Further resources

Questions and feedback

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