Skip to main content

StructSchema

Defines the sub-fields of a struct-array field and validates the rules applied to those sub-fields.

go
type StructSchema struct {
Fields []*Field
}

Request Syntax

Creates an empty struct schema.

go
entity.NewStructSchema()

METHODS:

  • WithField(field *Field) *StructSchema

    This appends a sub-field definition.

  • Validate(parentName string) error

    This rejects empty, duplicate, nested, sparse-vector, nullable, key, auto-ID, dynamic, and default-valued sub-fields.

RETURN TYPE:

StructSchema

RETURNS:

Represents the schema of a struct field, including nested field definitions.

  • Fields ([]Field*) -

    This contains the struct-array sub-field definitions.

Example

Demonstrates StructSchema usage.

go
import (
"fmt"

"github.com/milvus-io/milvus/client/v3/entity"
)

structSchema := entity.NewStructSchema().
WithField(entity.NewField().WithName("text").WithDataType(entity.FieldTypeVarChar).WithMaxLength(256)).
WithField(entity.NewField().WithName("embedding").WithDataType(entity.FieldTypeFloatVector).WithDim(8))

err := structSchema.Validate("chunks")
fmt.Println(err)
Minimum SDK versionv3.0.x
Ctrl I