Skip to main content

add_collection_struct_field()

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

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

Request Syntax​

rust
let request = AddCollectionStructFieldRequest::builder()
.collection_name("books")
.struct_field(
StructFieldSchema::new()
.name("events")
.max_capacity(16)
.nullable(true)
.type_param("mmap.enabled", "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.

    Struct fields also accept type parameters with type_param(), such as mmap.enabled and warmup. Existing keys are preserved when a map is supplied with type_params().

RETURN TYPE:

Result<()>

RETURNS:

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

Example​

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