StructFieldSchema

Describes a struct field in a collection schema. A struct field groups a set of sub-fields (scalar or vector); each row stores a list of struct values (one per struct element).

public sealed class StructFieldSchema
{
    public StructFieldSchema(string name, string description = "")

    public string Name { get; }
    public string Description { get; }
    public int MaxCapacity { get; set; }
    public IDictionary<string, string> TypeParams { get; }
    public IList<FieldSchema> Fields { get; }
}

PARAMETERS:

  • Name (string) -

    The struct field’s name.

  • Description (string) -

    An optional description of the struct field.

  • MaxCapacity (int) -

    The maximum number of struct elements a single row may hold.

  • TypeParams (IDictionary) -

    Additional per-struct type_params to send on the wire, mirroring the Java SDK’s StructFieldSchema.typeParams / PyMilvus struct params. Supported keys include warmup and mmap.enabled (PyMilvus accepts mmap_enabled and normalizes it to mmap.enabled; the C# SDK passes wire keys verbatim, like FieldSchema.TypeParams on FieldSchema). Also populated when the schema is read back via DescribeCollection. Entries are added via the collection-initializer syntax TypeParams = { ... }.

  • Fields (IList) -

    The sub-fields of the struct. Sub-fields cannot be primary/partition/clustering keys, cannot be auto-id, nullable, or have a default value. See FieldSchema.

METHODS:

  • StructFieldSchema(string name, string description = "") -

    Initializes a new struct field schema.

Example

using Milvus.Client.V2;
using Milvus.Client.V2.Requests.Collection;
using Milvus.Client.V2.Types;

using var client = new MilvusClientV2(new ConnectConfig
{
    Uri = "localhost:19530",
    Username = "root",
    Password = "Milvus"
});

var structField = new StructFieldSchema("book_info", "Per-book metadata");
structField.MaxCapacity = 5;
structField.Fields.Add(FieldSchema.CreateVarchar("author", maxLength: 128));
structField.Fields.Add(FieldSchema.CreateFloatVector("thumbnail", dimension: 64));

var schema = new CollectionSchema { Name = "my_collection" };
schema.Fields.Add(new FieldSchema("id", DataType.Int64, isPrimaryKey: true, autoId: true));
schema.StructFields.Add(structField);

await client.CreateCollectionAsync(new CreateCollectionReq
{
    CollectionName = "my_collection",
    Schema = schema
});

Try Managed Milvus for Free

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

Get Started
Feedback

Was this page helpful?