Upsert function
To upsert documents, pass a list of documents to theupsert()
function:
- Every document must have a string
_id
field. - If a document with the specified
_id
doesn’t exist, a new document will be inserted. - If a document with the same
_id
already 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.Each document you send is serialized as a Protocol Buffers (protobuf) message. The encoded size of that message must be 128KB or smaller.
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() |
F32 vector | list[float] | number[] | f32_vector() |
U8 vector | use helper | use helper | u8_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() |
Bytes | use helper | use helper | bytes() |