< Docs
  • Java


A MilvusClient interface. This method manually triggers a compaction operation on the server side.

Compaction is automatically triggerd by the Milvus server under certain conditions.
R<ManualCompactionResponse> manualCompact(ManualCompactParam requestParam);


Use the ManualCompactParam.Builder to construct a ManualCompactParam object.

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

Methods of ManualCompactParam.Builder:

withCollectionName(String collectionName)Sets the collection name. The collection name cannot be empty or null.collectionName: The name of the collection that needs to be manually compacted.
build()Constructs a ManualCompactParam object.N/A

The could throw the following exceptions:

  • ParamException: error if the parameter is invalid.


This method catches all the exceptions and returns an R<ManualCompactionResponse> 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.Unknow and error message of the exception.

  • If the API succeeds, it returns a valid ManualCompactionResponse held by the R template. The ManualCompactionResponse contains an ID of this compaction operation, of which you can check the state by getCompactionState() or getCompactionStateWithPlans() method.


import io.milvus.param.*;

ManualCompactParam param = ManualCompactParam.newBuilder()
R<ManualCompactionResponse> response = client.manualCompact(param);
if (response.getStatus() != R.Status.Success.getCode()) {

System.out.println("Compaction ID: " + response.getData().getCompactionID());