{"record":{"id":"ec54e40c754ba3b0","repo":"RyanCodrai/turbovec","slug":"turboquantvectorstore-requires-a-pre-computed-quer","errorCode":null,"errorMessage":"TurboQuantVectorStore requires a pre-computed query_embedding (is_embedding_query=True).","messagePattern":"TurboQuantVectorStore requires a pre-computed query_embedding \\(is_embedding_query=True\\)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"turbovec-python/python/turbovec/llama_index.py","lineNumber":804,"sourceCode":"    def query(self, query: VectorStoreQuery, **_: Any) -> VectorStoreQueryResult:\n        # MMR / SVM / LINEAR_REGRESSION / HYBRID etc. all need access to\n        # full-precision vectors (for pairwise diversity, learned scoring,\n        # or sparse-dense fusion). turbovec discards full precision after\n        # quantization, so any non-DEFAULT mode is unsupportable here.\n        # Raise loudly instead of silently treating it as DEFAULT, which\n        # the previous impl did and which let callers think they were\n        # getting e.g. MMR diversity when they were not.\n        if query.mode != VectorStoreQueryMode.DEFAULT:\n            raise NotImplementedError(\n                f\"TurboQuantVectorStore does not support query mode \"\n                f\"{query.mode!r}. Only VectorStoreQueryMode.DEFAULT is \"\n                \"supported — MMR / SVM / hybrid modes need access to \"\n                \"full-precision vectors which turbovec discards after \"\n                \"quantization. Maintain a parallel store with full vectors \"\n                \"if you need a non-default scoring mode.\"\n            )\n        if query.query_embedding is None:\n            raise ValueError(\n                \"TurboQuantVectorStore requires a pre-computed query_embedding \"\n                \"(is_embedding_query=True).\"\n            )\n        qvec = np.asarray(query.query_embedding, dtype=np.float32)\n        if qvec.ndim == 1:\n            qvec = qvec[None, :]\n        # Cosine mode: normalize the query so the raw inner product\n        # against unit node vectors is true cosine similarity.\n        if self._similarity == COSINE:\n            qvec = l2_normalize_rows(qvec)\n        if not qvec.flags[\"C_CONTIGUOUS\"]:\n            qvec = np.ascontiguousarray(qvec)\n\n        if len(self._index) == 0:\n            return VectorStoreQueryResult(nodes=[], similarities=[], ids=[])\n\n        # Truthiness is deliberate: node_ids=[] / doc_ids=[] mean \"no\n        # restriction\", per the retriever calling convention — see the","sourceCodeStart":786,"sourceCodeEnd":822,"githubUrl":"https://github.com/RyanCodrai/turbovec/blob/ccab9f325e6ce2a270a87daf01ae4e443bcf2d49/turbovec-python/python/turbovec/llama_index.py#L786-L822","documentation":"TurboQuantVectorStore (llama_index integration) only supports embedding-based queries. Because turbovec quantizes vectors to low precision, it cannot re-embed a raw query string itself, so query() demands a pre-computed query_embedding. Calling query() without one (i.e. is_embedding_query=False) is rejected with this ValueError.","triggerScenarios":"Calling store.query(query) where query.query_embedding is None — typically a QueryWithEmbedding built from a plain text query without is_embedding_query=True, or a Query object whose embedding was never populated.","commonSituations":"Migrating from llama_index's SimpleVectorStore (which embeds query text internally) to TurboQuantVectorStore; calling query() directly with a text-only Query instead of going through the embedding-retriever pipeline; custom retriever code that skips the embed step.","solutions":["Embed the query text first and pass a QueryWithEmbedding with is_embedding_query=True and query_embedding set.","Use llama_index's retriever (TurboQuantVectorStore as the store behind an index) so the embedding step happens automatically.","If you need text-query support, maintain a parallel full-precision store; turbovec discards full vectors after quantization."],"exampleFix":"// before\nresults = store.query(Query(query_str=\"hello\"))\n// after\nqvec = embed_model.get_query_embedding(\"hello\")\nresults = store.query(QueryWithEmbedding(\n    query_str=\"hello\",\n    query_embedding=qvec,\n    is_embedding_query=True,\n))","handlingStrategy":"validation","validationCode":"if getattr(query, 'query_embedding', None) is None:\n    query = embed_and_wrap(query.query_str)  # produce QueryWithEmbedding(is_embedding_query=True)","typeGuard":"def has_embedding(q) -> bool:\n    return getattr(q, 'query_embedding', None) is not None","tryCatchPattern":null,"preventionTips":["Always route queries through llama_index's retriever so embedding happens automatically.","Never construct Query objects with is_embedding_query=False against TurboQuantVectorStore.","Unit-test the query path with an embedding-populated fixture."],"tags":["python","llama-index","vector-store","missing-embedding"],"backgroundTag":"missing-required-argument","analyzedSha":"ccab9f325e6ce2a270a87daf01ae4e443bcf2d49","analyzedAt":"2026-09-06T08:39:18.516Z","contentChangedAt":"2026-09-06T08:39:18.516Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}