Text vs Vector Search in MongoDB Atlas
In this post, we’re gonna run a side-by-side search spin-off in MongoDB Atlas:
- Atlas Search (keyword / full-text) using the
textoperator (scored by BM25 by default). - Atlas Vector Search (semantic / meaning-based) using the
$vectorSearchaggregation stage (nearest-neighbor search over embeddings).
The goal isn’t to “replace” text search. It’s to experience, hands-on, why vector search is different.
- Keyword search answers: “Which documents contain these words?” (BM25-style ranking).
- Vector search answers: “Which documents are most similar in meaning?” (closest vectors).
To keep this truly “Hello World” and fast to reproduce, we’ll use Atlas’s sample dataset (sample_mflix) which includes an embedded_movies collection designed for vector search experiments.
Prerequisites
Accounts + cloud setup
- A MongoDB Atlas account and a project.
- An Atlas cluster you can connect to (Free Tier / Flex is fine for this tutorial).
Local tools
- Git (to clone the repo / commit your changes)
mongosh(MongoDB Shell) or MongoDB Compass
Atlas data + indexes we’ll create
- Load Atlas Sample Dataset →
sample_mflixdatabase, includingembedded_movies - We will create:
- A Search (text) index for keyword search using the
textoperator (BM25 scoring by default). - A Vector Search index so
$vectorSearchcan run.
- A Search (text) index for keyword search using the
Optional (nice to haves)
- Node.js (if you want a tiny “demo app” wrapper around the queries later).
- Atlas CLI (not required for this, but handy once you automate)