Said
01/25/2025, 11:43 AMexport TYPESENSE_API_KEY=xyz
mkdir -p "$(pwd)"/typesense-data
docker run -p 8108:8108 \
-v "$(pwd)"/typesense-data:/data typesense/typesense:27.1 \
--data-dir /data \
--api-key=$TYPESENSE_API_KEY \
--enable-cors
curl "<http://localhost:8108/collections>" -X POST \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"name": "nested_test",
"fields": [
{"name": "id", "type": "string"},
{"name": "title", "type": "string"},
{"name": "Summary", "type": "string"},
{"name": "Dense_Summary_Embedding", "type": "float[]", "num_dim": 5},
{
"name": "chunks",
"type": "object[]",
"fields": [
{"name": "text", "type": "string"},
{"name": "vector", "type": "float[]", "num_dim": 5}
]
}
],
"enable_nested_fields": true
}'
curl "<http://localhost:8108/collections/nested_test/documents>" -X POST \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"id": "1",
"title": "Test Document",
"Summary": "This is an example summary of document 1",
"Dense_Summary_Embedding": [0.1, 0.2, 0.3, 0.4, 0.5],
"chunks": [
{"text": "First chunk", "vector": [0.1, 0.2, 0.3, 0.1, 0.2]},
{"text": "Second chunk", "vector": [0.4, 0.5, 0.6, 0.4, 0.5]}
]
}'
curl "<http://localhost:8108/multi_search>" -X POST \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"searches": [
{
"collection": "nested_test",
"q": "*",
"vector_query": "chunks.vector:([0.1, 0.2, 0.3, 0.1, 0.2], k:10)"
}
]
}'
And the error message:
`{"results":[{"code":400,"error":"Field chunks.vector
does not have a vector query index."}]}`