{"record":{"id":"b3c213b965714ec8","repo":"MemPalace/mempalace","slug":"qdrant-collection-self-collection-name-r-expect-b3c213","errorCode":null,"errorMessage":"qdrant collection {self._collection_name!r} expects embedding dimension {self._known_dimension}, got {int(q.size)}","messagePattern":"qdrant collection (.+?) expects embedding dimension (.+?), got (.+?)","errorType":"validation","errorClass":"DimensionMismatchError","httpStatus":null,"severity":"error","filePath":"mempalace/backends/qdrant.py","lineNumber":991,"sourceCode":"                raise CollectionNotInitializedError(self._collection_name)\n            return QueryResult.empty(\n                num_queries=len(query_embeddings),\n                embeddings_requested=bool(include and \"embeddings\" in include),\n            )\n\n        spec = _IncludeSpec.resolve(include, default_distances=True)\n        q_filter = _qdrant_filter(where)\n        outer_ids: list[list[str]] = []\n        outer_docs: list[list[str]] = []\n        outer_metas: list[list[dict]] = []\n        outer_dists: list[list[float]] = []\n        outer_embeds: list[list[list[float]]] = []\n        for query_vector in query_embeddings:\n            q = _as_vector_array(query_vector)\n            if self._known_dimension is None:\n                self._known_dimension = self._remote_dimension()\n            if self._known_dimension is not None and int(q.size) != self._known_dimension:\n                raise DimensionMismatchError(\n                    f\"qdrant collection {self._collection_name!r} expects \"\n                    f\"embedding dimension {self._known_dimension}, got {int(q.size)}\"\n                )\n            points = self._client.query_points(\n                self._remote_collection,\n                vector=q.astype(float).tolist(),\n                limit=n_results,\n                qdrant_filter=q_filter,\n                with_vector=spec.embeddings,\n            )\n            rows = [_payload_row(point) for point in points]\n            outer_ids.append([row[\"id\"] for row in rows])\n            outer_docs.append([row[\"document\"] for row in rows] if spec.documents else [])\n            outer_metas.append([row[\"metadata\"] for row in rows] if spec.metadatas else [])\n            outer_dists.append(\n                [_qdrant_score_to_distance(row[\"score\"]) for row in rows] if spec.distances else []\n            )\n            if spec.embeddings:","sourceCodeStart":973,"sourceCodeEnd":1009,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/backends/qdrant.py#L973-L1009","documentation":"Raised by QdrantCollection.query() when a query embedding's dimension differs from the collection's known vector size (cached, or fetched from the remote collection config at query time). DimensionMismatchError: queries must use the same embedding model family/dimension as the stored data or vector similarity is meaningless.","triggerScenarios":"Querying a 768-dim collection with 384-dim query vectors — embedding the query with a different model than the one that built the collection; or after switching the local embed model between ingest and search without rebuilding.","commonSituations":"Ollama model changed (e.g. default pulled model differs) between indexing and querying; search path uses a hardcoded/different embedder than the ingest path; multiple apps sharing the Qdrant collection with different model configs.","solutions":["Embed queries with exactly the model used for ingest (check get_stored_embedder_identity)","Migrate the collection: re-embed all documents with the new model (new collection), then query with that model","Centralize embedder config in one place so ingest and search cannot diverge","The error message states expected vs got dims — confirm against your models' output sizes"],"exampleFix":"# before\n# collection built with 768-dim model A; querying with 384-dim model B:\ncollection.query(query_embeddings=[model_b.embed(q)])  # DimensionMismatchError\n// after\ncollection.query(query_embeddings=[model_a.embed(q)])  # same model as ingest","handlingStrategy":"try-catch","validationCode":"dim = collection._remote_dimension() or collection._known_dimension\nif dim is not None and len(query_vec) != dim:\n    raise ValueError(f\"query dim {len(query_vec)} != collection dim {dim}; wrong embed model?\")","typeGuard":null,"tryCatchPattern":"from mempalace.backends.base import DimensionMismatchError\ntry:\n    res = collection.query(query_embeddings=[qvec])\nexcept DimensionMismatchError:\n    qvec = ingest_model.embed(query_text)  # re-embed with the ingest-time model","preventionTips":["Load the embed model by explicit name/id, not by alias or default, at query time","Verify get_stored_embedder_identity() matches the live embedder before searching","One model per palace; migrate collections fully when changing models"],"tags":["dimension-mismatch","search","embeddings","qdrant"],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}