alterAlias()
This operation reassigns the alias of one collection to another.
public void alterAlias(AlterAliasReq request)
Request Syntax
alterAlias(AlterAliasReq.builder()
.alias(String alias)
.collectionName(String collectionName)
.build()
)
BUILDER METHODS:
alias(String alias)
The alias of the collection. Note that the alias should exist beforehand.
what is a collection alias?
A collection alias is an additional name for a collection. Collection aliases are useful when you want to switch your application to a new collection without any changes to your code.
In Milvus, a collection alias is a globally unique identifier. One alias can only be assigned to exactly one collection. Conversely, a collection can have multiple aliases.
Below is an example of reassigning the alias of one collection to another:
Suppose there are two collections:
collection_1
andcollection_2
. There is also a collection alias namedbob
, which was originally assigned tocollection_1
:collection_1
's alias = [“bob”]collection_2
's alias = []
After calling the
alterAlias
function with the parameterscollection_2
andbob
:collection_1
's alias = []collection_2
's alias = [“bob”]
collectionName(String collectionName)
The name of the target collection to reassign an alias to.
RETURNS:
void
EXCEPTIONS:
MilvusClientExceptions
This exception will be raised when any error occurs during this operation.
Example
// alter the alias for collection "test"
AlterAliasReq alterAliasReq = AlterAliasReq.builder()
.collectionName("test")
.alias("test_alias2")
.build();
client.alterAlias(alterAliasReq);