- Must include a unique
_idfield - Must conform to the collection schema for indexed fields
Upsert documents in a collection
To upsert documents, pass a list of documents to theupsert() function:
- Every document must have a string
_idfield. - If a document with the specified
_iddoesn’t exist, a new document will be inserted. - If a document with the same
_idalready exists, the existing document will be replaced with the new one.
The
upsert() function does not perform a partial update or merge - the entire document is being replaced.Additional (non-schema) fields
You may include fields that are not defined in the collection schema. These fields:- Are stored with the document
- Can be returned to the client in query results
- Can be used for filtering in queries
Supported types
TopK documents are a flat structure of key-value pairs. The following value types are supported:| Type | Python Type | JavaScript Type | Helper Function |
|---|---|---|---|
| String | str | string | - |
| Integer | int | number | - |
| Float | float | number | - |
| Boolean | bool | boolean | - |
| String list | list[str] | string[] | string_list() |
| F32 list | list[float] | number[] | f32_list() |
| F64 list | use helper | use helper | f64_list() |
| I32 list | use helper | use helper | i32_list() |
| I64 list | use helper | use helper | i64_list() |
| U32 list | use helper | use helper | u32_list() |
| F8 vector | use helper | use helper | f8_vector() |
| F16 vector | use helper | use helper | f16_vector() |
| F32 vector | list[float] | number[] | f32_vector() |
| U8 vector | use helper | use helper | u8_vector() |
| I8 vector | use helper | use helper | i8_vector() |
| Binary vector | use helper | use helper | binary_vector() |
| F32 sparse vector | use helper | use helper | f32_sparse_vector() |
| U8 sparse vector | use helper | use helper | u8_sparse_vector() |
| Matrix | use helper | use helper | matrix() |
| Bytes | use helper | use helper | bytes() |