milvus-logo
LFAI
< Docs
  • Java

renameCollection()

A MilvusClient interface. This method renames the specified collection.

R<RpcStatus> renameCollection(RenameCollectionParam requestParam)

RenameCollectionParam

Use the RenameCollectionParam.Builder to construct a RenameCollectionParam object.

import io.milvus.param.RenameCollectionParam;
RenameCollectionParam.Builder builder = RenameCollectionParam.newBuilder();

Methods of RenameCollectionParam.Builder:

Method

Description

Parameters

withOldCollectionName(String oldCollectionName)

Sets the old collection name. Old collection name cannot be empty or null.

oldCollectionName: The old name of the collection to rename.

withNewCollectionName(String newCollectionName)

Sets the new collection name. New collection name cannot be empty or null.

newCollectionName: The new name of the collection to rename.

withOldDatabaseName(String databaseName)

Sets the database name of the old collection. database name can be null for default database.

databaseName: The database name.

withNewDatabaseName(String databaseName)

Sets the database name of the new collection. database name can be null for default database.

databaseName: The database name.

build()

Constructs a RenameCollectionParam object.

N/A

The RenameCollectionParam.Builder.build() can throw the following exceptions:

  • ParamException: error if the parameter is invalid.

Returns

This method catches all the exceptions and returns an R<RpcStatus> object.

  • If the API fails on the server side, it returns the error code and message from the server.

  • If the API fails by RPC exception, it returns R.Status.Unknown and the error message of the exception.

  • If the API succeeds, it returns R.Status.Success.

Example

import io.milvus.param.*;

RenameCollectionParam param = RenameCollectionParam.newBuilder()
        .withOldCollectionName(OLD_COLLECTION_NAME)
        .withNewCollectionName(NEW_COLLECTION_NAME)
        .build();
R<Boolean> response = client.renameCollection(param);
if (response.getStatus() != R.Status.Success.getCode()) {
    System.out.println(response.getMessage());
}
Feedback

Was this page helpful?