< Docs
  • Java


MilvusClient interface. This method returns the state of a compaction operation, to know whether this operation has been finished.

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:

Method Description Parameters
withCompactionID(Long compactionID) Set the compaction action id to get state. compactionID: The compaction operation ID.
build() Construct 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.Unknown and 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
Type Code Description
UndefiedState 0 For internal usage.
Executing 1 Compaction is in executing
Completed 2 Compaction 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());