AddCollectionStructField()

Adds a struct (array-of-structs) field to an existing collection.

pub async fn add_collection_struct_field(&self, request: AddCollectionStructFieldRequest) -> Result<()>

Request Syntax

let request = AddCollectionStructFieldRequest::builder()
    .collection_name("books")
    .struct_field(
        StructFieldSchema::new()
            .name("events")
            .max_capacity(16)
            .nullable(true)
            .add_field(
                FieldSchema::new()
                    .name("embedding")
                    .data_type(DataType::FloatVector)
                    .dimension(128),
            ),
    )
    .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 alter. Required.

  • struct_field: Option<StructFieldSchema>

    The StructFieldSchema describing the new struct field. Adding a struct field to an existing collection requires nullable(true). Required.

RETURN TYPE:

Result<()>

RETURNS:

Returns an empty result indicating success. Returns Error on failure.

Example

let request = AddCollectionStructFieldRequest::builder()
    .collection_name("books")
    .struct_field(
        StructFieldSchema::new()
            .name("events")
            .max_capacity(16)
            .nullable(true)
            .add_field(
                FieldSchema::new()
                    .name("embedding")
                    .data_type(DataType::FloatVector)
                    .dimension(128),
            ),
    )
    .build()?;
client.add_collection_struct_field(request).await?;

Try Managed Milvus for Free

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

Get Started
Feedback

Was this page helpful?