A MilvusClient interface. This method returns the state of a compaction operation and shows if the specified compaction operation has completed.

R<GetCompactionStateResponse> getCompactionState(GetCompactionStateParam requestParam);


Use the GetCompactionStateParam.Builder to construct a GetCompactionStateParam object.

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

Methods of GetCompactionStateParam.Builder:

withCompactionID(Long compactionID)Sets the ID of the compaction.compactionID: The ID of the compaction operation to be checked.
build()Constructs a GetCompactionStateParam 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<GetCompactionStateResponse> 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 the error message of the exception.

  • If the API succeeds, it returns a valid GetCompactionStateResponse held by the R template.


Use the getState() of GetCompactionStateResponse to get the compaction state:

package io.milvus.grpc;
public enum CompactionState
UndefiedState0For internal usage.
Executing1Compaction is in execution.
Completed2Compaction is completed.


import io.milvus.param.*;
import io.milvus.grpc.GetCompactionStateResponse;

GetCompactionStateParam param = GetCompactionStateParam.newBuilder()
R<GetCompactionStateResponse> response = client.getCompactionState(param);
if (response.getStatus() != R.Status.Success.getCode()) {

System.out.println("Compaction state: " + response.getData().getState());