< Docs
  • Java


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


Milvus server can automatically trigger compaction operation in 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:

Method Description Parameters
withCollectionName(String collectionName) Sets the collection name. Collection name cannot be empty or null. collectionName: The target collection name.
build() Construct a ManualCompactParam object. N/A

The can 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.Unknown 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, 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());