メインコンテンツまでスキップ

get_compaction_state()

Addedv2.6.xModifiedv2.6.x

This operation returns the current state of a compaction job. Use this after calling compact() to verify that compaction has completed.

📘Notes

This method was previously named get_compact_state(). The behavior is identical.

Request syntax

client.get_compaction_state(
job_id: int,
timeout: float = None
) -> str

PARAMETERS:

  • job_id (int) -

    [REQUIRED]

    The ID of the compaction job returned by compact().

  • timeout (float | None) -

    The timeout duration for this operation. Setting this to None indicates that this operation timeouts when any response arrives or any error occurs.

RETURN TYPE:

str

RETURNS:

The state name of the compaction job. Possible values are "UndefiedState", "Executing", and "Completed".

EXCEPTIONS:

  • MilvusException

    This exception will be raised when the job ID is invalid or the server encounters an error.

Example

from pymilvus import MilvusClient

client = MilvusClient(uri="YOUR_CLUSTER_ENDPOINT")

# Start compaction and check its state
job_id = client.compact(collection_name="my_collection")
state = client.get_compaction_state(job_id=job_id)
print(state) # "Executing" or "Completed"