BLOB type (HTTP)
|
For details about additional languages, see: |
Use the blob type for binary data.
Although you can store binary-encoded vector data in a blob column, you cannot create a vector index or perform a vector search on the column.
Instead, use the vector type to store vector data.
|
Due to a known issue with filtering on |
You can insert binary data as a Base64-encoded string with $binary.
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME/TABLE_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"insertOne": {
"document": {
"example_blob" : {"$binary": "PaPXCr8euFI+x64U"},
"title": "Example"
}
}
}'
If you use $binary, the underlying bytes must represent 32-bit floating point values in big-endian format.
The byte sequence must be Base64-encoded, with = padding if needed.
For example:
-
[0.1, -0.2, 0.3]is"PczMzb5MzM0+mZma" -
[0.1, 0.2]is"PczMzT5MzM0=" -
[10, 10.5, 100, -91.19]is"QSAAAEEoAABCyAAAwrZhSA=="
The following script can binary-encode vectors:
python
import base64
import struct
input_vector = [0.1, -0.2, 0.3]
d = len(input_vector)
pack_format = ">" + "f" * d
binary_encode = base64.b64encode(struct.pack(pack_format, *input_vector)).decode()