Creating a collection
Callcreate()
on client.collections()
:
Collection name (unique within account)
Document structure and search capabilities
Field names starting with
_
are reserved for internal use.Schema
Opt-in schema
TopK is schemaless-by-default. Fields without types can store any value. When types are specified, data is validated during upsert. Indexed fields require explicit types.Field types
Type | Use case |
---|---|
text() | Strings, descriptions, content |
bytes() | Binary data, images, files |
int() | Integers, counts, IDs |
float() | Decimal numbers, prices |
bool() | True/false values |
list(value_type) | Arrays (text, integer, float) |
f32_vector(dim) | Dense embeddings (most common) |
u8_vector(dim) | Quantized embeddings |
i8_vector(dim) | Signed quantized embeddings |
binary_vector(dim) | Binary embeddings |
f32_sparse_vector() | Sparse embeddings |
u8_sparse_vector() | Quantized sparse embeddings |
Required fields
Fields are optional by default. Add.required()
to make them mandatory:
Indexes
Indexes enable search capabilities. Without indexes, only exact filtering is possible.Index types
Vector Index
Used for vector search. Supports dimensions up to 2^14.Vector Type | cosine | euclidean | dot_product | hamming |
---|---|---|---|---|
f32_vector | ✅ | ✅ | ✅ | — |
u8_vector | ✅ | ✅ | ✅ | — |
i8_vector | ✅ | ✅ | ✅ | — |
f32_sparse_vector | — | — | ✅ | — |
u8_sparse_vector | — | — | ✅ | — |
binary_vector | — | — | — | ✅ |