Skip to main content

renameCollection()

This operation renames an existing collection.

public void renameCollection(RenameCollectionReq request)

Request Syntax

renameCollection(RenameCollectionReq.builder()
.collectionName(String collectionName)
.newCollectionName(String newCollectionName)
.build()
)

BUILDER METHODS:

  • collectionName(String collectionName)

    The name of an existing collection.

    Setting this to a non-existing collection results in a MilvusException.

  • newCollectionName(String newCollectionName)

    The name of the target collection after this operation.

    Setting this to the value of old_name results in a MilvusException.

RETURNS:

void

EXCEPTIONS:

  • MilvusClientExceptions

    This exception will be raised when any error occurs during this operation.

Example

import io.milvus.v2.client.ConnectConfig;
import io.milvus.v2.client.MilvusClientV2;
import io.milvus.v2.service.collection.request.RenameCollectionReq;

// 1. Set up a client
ConnectConfig connectConfig = ConnectConfig.builder()
.uri("YOUR_CLUSTER_ENDPOINT")
.token("YOUR_CLUSTER_TOKEN")
.build();

MilvusClientV2 client = new MilvusClientV2(connectConfig);

// 2. Rename collection "test" to "test2"
RenameCollectionReq renameCollectionReq = RenameCollectionReq.builder()
.collectionName("test")
.newCollectionName("test2")
.build();
client.renameCollection(renameCollectionReq);