{"record":{"id":"5728ab2f0d4477ea","repo":"MemPalace/mempalace","slug":"pgvector-requires-query-embeddings-use-palace-get","errorCode":null,"errorMessage":"pgvector requires query_embeddings; use palace.get_collection wrapper","messagePattern":"pgvector requires query_embeddings; use palace\\.get_collection wrapper","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mempalace/backends/pgvector.py","lineNumber":1080,"sourceCode":"            ids=outer_ids,\n            documents=outer_docs,\n            metadatas=outer_metas,\n            distances=outer_dists,\n            embeddings=outer_embeds if spec.embeddings else None,\n        )\n\n    def query(\n        self,\n        *,\n        query_texts=None,\n        query_embeddings=None,\n        n_results=10,\n        where=None,\n        where_document=None,\n        include=None,\n    ) -> QueryResult:\n        if query_texts is not None:\n            raise ValueError(\n                \"pgvector requires query_embeddings; use palace.get_collection wrapper\"\n            )\n        if query_embeddings is None:\n            raise ValueError(\"query requires query_embeddings\")\n        if not query_embeddings:\n            raise ValueError(\"query input must be a non-empty list\")\n        _validate_where(where)\n        _validate_where(where_document)\n        if _requires_local_filter(where, where_document):\n            return self._query_local_exact(\n                query_embeddings=query_embeddings,\n                n_results=n_results,\n                where=where,\n                where_document=where_document,\n                include=include,\n            )\n        self._ensure_open()\n        if not self._table_exists():","sourceCodeStart":1062,"sourceCodeEnd":1098,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/backends/pgvector.py#L1062-L1098","documentation":"The pgvector backend has no embedder attached, so it cannot turn query_texts into vectors. query() rejects any call that passes query_texts and tells you to obtain the collection through the palace.get_collection() wrapper, which wires up an embedder and converts texts to embeddings for you.","triggerScenarios":"Calling PgVectorCollection.query(query_texts=[\"hello\"]) directly, or piping a ChromaDB-style call with query_texts into a collection object obtained from the raw pgvector backend instead of palace.get_collection().","commonSituations":"Porting code written against ChromaDB (whose query accepts query_texts) to the pgvector backend; grabbing the collection from backend.get_collection() and assuming the same text-query surface.","solutions":["Open the collection via palace.get_collection(...) and call query(query_texts=...) on that wrapper, which embeds the texts first.","Or embed the texts yourself with your embedder and call query(query_embeddings=[...]) on the pgvector collection.","Remove query_texts entirely if you already have embeddings."],"exampleFix":"# before\ncol = pgvector_backend.get_collection(palace, \"notes\")\ncol.query(query_texts=[\"hello\"], n_results=5)\n\n# after\ncol = palace.get_collection(\"notes\")\ncol.query(query_texts=[\"hello\"], n_results=5)","handlingStrategy":"validation","validationCode":"# use the palace wrapper, which embeds texts for you\ncol = palace.get_collection(\"notes\")\ncol.query(query_texts=[\"hello\"], n_results=5)","typeGuard":null,"tryCatchPattern":"try:\n    col.query(query_texts=[\"hello\"])\nexcept ValueError as e:\n    if \"use palace.get_collection wrapper\" in str(e):\n        col = palace.get_collection(\"notes\")\n        results = col.query(query_texts=[\"hello\"])","preventionTips":["Always obtain collections via palace.get_collection() unless you manage embeddings yourself.","Keep one code path for queries: either always texts via the wrapper or always embeddings via the raw backend.","Document which collections are 'raw backend' vs 'wrapped' in your project."],"tags":["pgvector","embeddings","api-misuse"],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}