Overview
VectorSchema defines a vector field in a collection schema. Vector fields are used for similarity search operations and can be configured with different data types, dimensions, and index parameters.
Constructor
Parameters
Name of the vector field. Must be unique within the collection.
Vector data type. Supported types:
DataType.VECTOR_FP32- 32-bit floating point (most common)DataType.VECTOR_FP16- 16-bit floating point (memory efficient)DataType.VECTOR_FP64- 64-bit floating point (high precision)DataType.VECTOR_INT8- 8-bit integer (quantized)DataType.SPARSE_VECTOR_FP32- Sparse 32-bit floatDataType.SPARSE_VECTOR_FP16- Sparse 16-bit float
Dimensionality of the vector. Must be greater than 0 for dense vectors. For sparse vectors, may be
None or 0. Defaults to 0.Index configuration for this vector field. Determines the search algorithm and performance characteristics. Defaults to
FlatIndexParam() if not specified.HnswIndexParam- HNSW graph index (balanced speed/accuracy)FlatIndexParam- Brute-force search (highest accuracy)IVFIndexParam- Inverted file index (large-scale data)
Raises
- ValueError: If
dimensionis negative or ifdata_typeis not a supported vector type - TypeError: If
nameis not a string
Properties
The name of the vector field (read-only).
The vector data type (read-only).
The dimensionality of the vector (read-only).
Index configuration for the vector (read-only).
Examples
Basic vector field
Vector with HNSW index
Memory-efficient vectors
Sparse vectors
Multiple vector fields in a schema
IVF index for large-scale data
MetricType Values
Themetric_type parameter in index configurations determines how vector similarity is calculated:
MetricType.L2- Euclidean distance (smaller is more similar)MetricType.IP- Inner product (larger is more similar)MetricType.COSINE- Cosine similarity (larger is more similar)
Index Selection Guide
| Index Type | Best For | Pros | Cons |
|---|---|---|---|
| Flat | Small datasets (under 10K vectors) | Perfect accuracy | Slow on large data |
| HNSW | Most use cases | Fast, accurate | Memory intensive |
| IVF | Large datasets (over 1M vectors) | Memory efficient | Requires training |
See Also
- CollectionSchema - Define complete collection structure
- DataType - All available data types
- HnswIndexParam - HNSW index configuration
- IVFIndexParam - IVF index configuration