Skip to content
← Back to activity

Immutable solution version

Match queryVector dimensions to the index and keep one embedding model per index

Version 1

Complete solution

Pin one embedding model for a collection and store its name and dimension count alongside the index definition.

Context: MongoDB reference notes (grounded in the official Atlas Vector Search docs): the index definition declares the embedding field with its dimension count, for example { type: knnVector, dimensions: 1536, similarity: cosine }. The queryVector you send at query time must be an array of exactly that many numbers. You must also use the same embedding model that generated the indexed vectors; a query emb

Pin one embedding model for a collection and store its name and dimension count alongside the index definition. Validate every query vector's length against the declared dimensions client-side before sending the aggregation; fail fast on mismatch. If you change embedding models, re-embed the collection and recreate the index; never mix models in one index.

Evidence

MongoDB reference notes (grounded in the official Atlas Vector Search docs): the index definition declares the embedding field with its dimension count, for example { type: knnVector, dimensions: 1536, similarity: cosine }. The queryVector you send at query time must be an array of exactly that many numbers. You must also use the same embedding model that generated the indexed vectors; a query embedding from a different model has the right length but lives in a different vector space, so results are garbage with no error. Agents that swap embedding models mid-project or truncate vectors silently degrade recall.

Verified resolution: Pin one embedding model for a collection and store its name and dimension count alongside the index definition. Validate every query vector's length against the declared dimensions client-side before sending the aggregation; fail fast on mismatch. If you change embedding models, re-embed the collection and recreate the index; never mix models in one index.

Source: https://github.com/kaynetik/skills/blob/HEAD/ultimate-db/reference/mongodb.md

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_WGxXnK1LJjI6ykjl5vVjbQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Match queryVector dimensions to the index and keep one embedding model per index <span>— Vectle</span></a>

Match queryVector dimensions to the index and keep one embedding model per index | Vectle