{"record":{"id":"1eea789d99269ad3","repo":"chroma-core/chroma","slug":"cannot-embed-string-query-for-key-key-no-embe","errorCode":null,"errorMessage":"Cannot embed string query for key '{key}': no embedding function configured for this key in the schema. Please provide an embedded vector or configure an embedding function.","messagePattern":"Cannot embed string query for key '(.+?)': no embedding function configured for this key in the schema\\. Please provide an embedded vector or configure an embedding function\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/api/models/CollectionCommon.py","lineNumber":927,"sourceCode":"                    except AttributeError:\n                        # Fallback if embed_query doesn't exist\n                        embeddings = embedding_func([query_text])\n\n                    if not embeddings or len(embeddings) != 1:\n                        raise ValueError(\n                            \"Embedding function returned unexpected number of embeddings\"\n                        )\n\n                    # Return a new Knn with the dense embedding\n                    return Knn(\n                        query=embeddings[0],\n                        key=knn.key,\n                        limit=knn.limit,\n                        default=knn.default,\n                        return_rank=knn.return_rank,\n                    )\n\n        raise ValueError(\n            f\"Cannot embed string query for key '{key}': \"\n            f\"no embedding function configured for this key in the schema. \"\n            f\"Please provide an embedded vector or configure an embedding function.\"\n        )\n\n    def _embed_rank_string_queries(self, rank: Any) -> Any:\n        \"\"\"Recursively embed string queries in Rank expressions.\n\n        Args:\n            rank: A Rank expression that may contain Knn objects with string queries\n\n        Returns:\n            A Rank expression with all string queries embedded\n        \"\"\"\n        # Import here to avoid circular dependency\n        from chromadb.execution.expression.operator import (\n            Knn,\n            Abs,","sourceCodeStart":909,"sourceCodeEnd":945,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/api/models/CollectionCommon.py#L909-L945","documentation":"The Knn query targets a key that exists in the schema, but that key's dense vector index has no embedding_function configured (dense_config.embedding_function is None and no sparse path matched). Chroma cannot turn the string query into a vector, so it tells you to send a vector or configure the function.","triggerScenarios":"`Knn(query=\"text\", key=<schema key>, ...)` where the key was declared with a float vector index but created without an embedding function in its config, and the collection has no usable fallback for that key.","commonSituations":"Collections built for precomputed-external embeddings (e.g. OpenAI vectors stored directly) later queried with raw strings; partial schema configs where only index type was set.","solutions":["Configure an embedding function on that key's dense vector index in the collection schema","Embed the string yourself and pass the resulting vector as the Knn query","Use a key that does have an embedding function, or the main embedding field"],"exampleFix":"# before\ncol.query(where=Knn(query=\"hello\", key=\"body_vec\", limit=5))  # no EF on body_vec\n\n# after\nvec = my_embedder.embed_query(\"hello\")\ncol.query(where=Knn(query=vec, key=\"body_vec\", limit=5))  # pass the vector","handlingStrategy":"validation","validationCode":"key_conf = collection.schema.keys.get(knn_key)\ndense_ef = (key_conf.float_list.vector_index.config.embedding_function\n            if key_conf and key_conf.float_list and key_conf.float_list.vector_index else None)\nif isinstance(knn_query, str) and dense_ef is None:\n    knn_query = my_embedder.embed_query(knn_query)  # embed it yourself","typeGuard":"def key_has_embedding_function(collection, key: str) -> bool:\n    schema = collection.schema\n    if schema is None or key not in schema.keys:\n        return False\n    kt = schema.keys[key]\n    dense = getattr(kt, \"float_list\", None)\n    cfg = getattr(getattr(dense, \"vector_index\", None), \"config\", None)\n    return getattr(cfg, \"embedding_function\", None) is not None","tryCatchPattern":null,"preventionTips":["Configure an embedding function on every schema key you intend to query with strings","For externally-embedded collections, always embed queries client-side and pass vectors","Add a startup check listing schema keys lacking an embedding function"],"tags":["schema","knn-query","embedding-function","configuration"],"backgroundTag":"missing-embedding-function","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}