Atlas Vector Search: vectorSearch
đź“‹ Lab Reference
Associated Lab File: vector-search-1.lab.js
🚀 Goal: Semantic Search That Wows
Your business wants to make searching for the perfect stay effortless and intelligent. Imagine a guest typing a natural-language query and instantly seeing smart, intent-aware suggestions—helping them find their dream destination even if they don’t use the exact words. As the backend engineer, you’re about to bring this next-level search to life with MongoDB Atlas Vector Search.
Harness the power of MongoDB Atlas Vector Search to build a semantic search feature your users will love!
đź§© Exercise: Semantic Search Like a Pro
-
Open the File
Head toserver/src/lab/and openvector-search-1.lab.js. -
Find the Function
Locate thevectorSearchfunction. -
Shape the Pipeline
- Add a
$vectorSearchstage using yourvector_indexindex. - Use the
descriptionfield as the vector search path. - Pass the user’s query string as the
queryparameter. - Add a filter on
property_typefor more relevant results. - Set
numCandidatesto 100 andlimitto 10 in the$vectorSearchstage.
- Add a
🚦 Test Your API
- Go to
server/src/lab/rest-lab. - Open
vector-search-1-lab.http. - Click Send Request to call the API.
- Confirm the response contains the expected, semantically relevant results.
🖥️ Frontend Validation
Type a natural-language query (e.g., "best view in hawaii") in the search bar and watch smart, relevant suggestions appear—powered by AI and vector search!
Check Exercise Status:
Go to the app and check if the exercise toggle shows green, indicating your implementation is correct.
With this step, you’re not just building a feature—you’re enabling a new era of discovery and delight for your users.
Ready to wow your guests with semantic search? Let’s get started!
