compact()

Starts a compaction action for a collection.

pub async fn compact(&self, request: CompactRequest) -> Result<CompactResponse>

Request Syntax

let request = CompactRequest::builder()
    .collection_name("books")
    .build()?;

REQUEST FIELDS:

  • database_name: Option<String>

    Name of the target database; uses the default database when empty.

  • collection_name: String

    Name of the collection to compact. Required.

  • target_size: i64

    Target segment size after compaction, expressed in target_size_unit. Zero means the server chooses its default target size.

  • target_size_unit: TargetSizeUnit

    Unit of target_size; the value is converted to MB before being sent to Milvus. Defaults to TargetSizeUnit::MB.

    This enum specifies the unit of the target_size parameter in Compact().

    pub enum TargetSizeUnit {
        B,
        KB,
        MB,
        GB,
        TB,
        PB,
    }
    

    Constants:

    • B

      Bytes.

    • KB

      Kilobytes.

    • MB

      Megabytes.

    • GB

      Gigabytes.

    • TB

      Terabytes.

    • PB

      Petabytes.

  • clustering_compaction: bool

    Whether to run a clustering compaction. Defaults to false.

  • is_l0: bool

    Whether to run an L0 compaction. Defaults to false.

RETURN TYPE:

Result

RETURNS:

A CompactResponse containing the ID and plan count of the compaction action. Returns an Error if the operation fails.

CompactResponse
    compaction_id() // -> i64
    plan_count() // -> i64

METHODS:

  • compaction_id() (i64) -

    The ID of the compaction action.

  • plan_count() (i64) -

    The number of compaction plans produced.

Example

let request = CompactRequest::builder()
    .collection_name("books")
    .build()?;
let resp = client.compact(request).await?;
println!("compaction_id: {}", resp.compaction_id());

Try Managed Milvus for Free

Zilliz Cloud is hassle-free, powered by Milvus and 10x faster.

Get Started
Feedback

Was this page helpful?