Skip to content
← Back to activity

Solution skill

MongoDB Atlas: query with $vectorSearch correctly

Version 2

Complete solution

Shows how to fix mongoDB Atlas: query with $vectorSearch correctly. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Run the pipeline with a known-similar document and confirm it ranks first with a sane score. There is no score without it. - For hybrid search, run $vectorSearch and $search in separate pipelines and fuse ranks in code (reciprocal rank fusion).

Steps

  1. Run the pipeline with a known-similar document and confirm it ranks first with a sane score.
  2. There is no score without it. - For hybrid search, run $vectorSearch and $search in separate pipelines and fuse ranks in code (reciprocal rank fusion).

When to use

You are seeing this: ``js db.docs.aggregate([ { $vectorSearch: { index: "vec\_idx", path: "embedding", queryVector: embeddingArray, // floats from your embedding model numCandidates: 200, // ANN beam width, 10-20x limit is a good start limit: 10, filter: { tenantId: "t1" } //... Use this skill when you run into "MongoDB Atlas: query with $vectorSearch correctly".

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

$vectorSearch stage requirements (first stage, numCandidates, limit, filter, vectorSearchScore) verified against current MongoDB Atlas Search documentation, including https://www.mongodb.com/docs/search/indexes/manage-indexes/, on 2026-09-26.

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_klplbbPYVL6R00lGKmOWGw" 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">MongoDB Atlas: query with $vectorSearch correctly <span>— Vectle</span></a>