Hey,

Hey, I’m encountering a persistent issue when querying a Cloudflare vector index using env.VECTORS.query() in a worker. Despite passing a valid 768-dimensional vector, I consistently receive the error. VECTOR_QUERY_ERROR (code = 40006): invalid query vector, expected 768 dimensions, and got 0 dimensions I have validated the entries with: console.log(“Vector length:”, queryVectorRaw.length); // 768 console.log(“typeof vector[0]:”, typeof queryVectorRaw[0]); // “number” console.log(“Array.isArray:”, Array.isArray(queryVectorRaw)); // true Has anyone experienced this before?
1 Reply
garvitg
garvitg3d ago
Hi @Shadow, thanks for reaching out! This error indicates that the supplied vector entity is not passed in the format expected by Vectorize. Please refer to the examples in https://developers.cloudflare.com/vectorize/best-practices/insert-vectors/ and ensure that the entity that you pass in the insert/upsert function is compatible with the expected format? If you think that your code matches the examples in the documentation link above, please feel free to share some snippets in this thread or over DM!
Cloudflare Docs
Insert vectors · Cloudflare Vectorize docs
Vectorize indexes allow you to insert vectors at any point: Vectorize will optimize the index behind the scenes to ensure that vector search remains efficient, even as new vectors are added or existing vectors updated.

Did you find this page helpful?