To pass a specific complex data type, use provided data constructors when inserting or querying your documents. TopK provides constructors for the following complex types:

f32_vector()

To pass a float32 vector, use the f32_vector() helper function:
from topk_sdk.data import f32_vector

f32_vector([0.12, 0.67, 0.82, 0.53])
When passing an array of numbers, it is by default considered a list of float32 values.

u8_vector()

To pass a u8 vector, use the u8_vector() helper function:
from topk_sdk.data import u8_vector

u8_vector([0, 1, 2, 3])

binary_vector()

To pass a binary vector, use the binary_vector() helper function:
from topk_sdk.data import binary_vector

binary_vector([0, 1, 1, 0])

f32_sparse_vector()

To pass a sparse vector with float32 values, use the f32_sparse_vector() helper function:
from topk_sdk.data import f32_sparse_vector

f32_sparse_vector({0: 0.12, 6: 0.67, 17: 0.82, 97: 0.53})

u8_sparse_vector()

To pass a sparse vector with 8-bit unsigned integer values, use the u8_sparse_vector() helper function:
from topk_sdk.data import u8_sparse_vector

u8_sparse_vector({0: 12, 6: 67, 17: 82, 97: 53})

f64_list()

To pass a list of 64-bit floating-point numbers, use the f64_list() helper function:
from topk_sdk.data import f64_list

f64_list([0.12, 0.67, 0.82, 0.53])

i32_list()

To pass a list of 32-bit signed integers, use the i32_list() helper function:
from topk_sdk.data import i32_list

i32_list([0, 1, 2, 3])

i64_list()

To pass a list of 64-bit signed integers, use the i64_list() helper function:
from topk_sdk.data import i64_list

i64_list([0, 1, 2, 3])

u32_list()

To pass a list of 32-bit unsigned integers, use the u32_list() helper function:
from topk_sdk.data import u32_list

u32_list([0, 1, 2, 3])

bytes()

To pass a byte object, use the bytes() helper function:
from topk_sdk.data import bytes

bytes([0, 1, 1, 0])