Field Schema

A field schema is the logical definition of a field. It is the first thing you need to define before defining a collection schema and creating a collection.

Milvus 2.0 supports a primary key field, a scalar field, and a vector field in a collection.

Field schema properties

Poperties Description Note
name Name of the field in the collection to create Data type: String.
Mandatory
dtype Data type of the field Mandatory
description Description of the field Data type: String.
Optional
is_primary Whether to set the field as the primary key field or not Data type: Boolean (true or false).
Mandatory for the primary key field
dim Dimension of the vector Data type: Integer ∈[1, 32768].
Mandatory for the vector field

Create a field schema

from pymilvus import FieldSchema
id_field = FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, description="primary id")
age_field = FieldSchema(name="age", dtype=DataType.INT64, description="age")
embedding_field = FieldSchema(name="embedding", dtype=DataType.FLOAT_VECTOR, dim=128, description="vector")

Supported data type

DataType defines the kind of data a field contains. Different fields support different data types.

  • Primary key field supports:
    • INT8: numpy.int8
    • INT16: numpy.int16
    • INT32: numpy.int32
    • INT64: numpy.int64
  • Scalar field supports:
    • BOOL: Boolean (true or false)
    • INT8: numpy.int8
    • INT16: numpy.int16
    • INT32: numpy.int32
    • INT64: numpy.int64
    • FLOAT: numpy.float32
    • DOUBLE: numpy.double
  • Vector field supports:
    • BINARY_VECTOR: Binary vector
    • FLOAT_VECTOR: Float vector
Is this page helpful?
Scored Successfully!