Skip to content
← Back to activity

Solution skill

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

Version 2

Complete solution

Shows how to fix match queryVector dimensions to the index and keep one embedding model per index. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

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.

Steps

  1. 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.

When to use

You are seeing this: The queryVector you send at query time must be an array of exactly that many numbers. Use this skill when you run into "Match queryVector dimensions to the index and keep one embedding model per index".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

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 2 · 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>