
Mongodb Search And Ai
Implement hybrid Atlas Search that merges vector and lexical results with rank or score fusion when building RAG or product search.
Overview
mongodb-search-and-ai is an agent skill for the Build phase that documents MongoDB Atlas hybrid search with `$rankFusion`, `$scoreFusion`, and lexical prefilters for vector search.
Install
npx skills add https://github.com/mongodb/agent-skills --skill mongodb-search-and-aiWhat is this skill?
- Three hybrid patterns: `$rankFusion`, `$scoreFusion`, and lexical prefilters via `vectorSearch` inside `$search`
- Decision table for when rank-based fusion vs score-based fusion vs lexical prefilter fits
- Indexing guidance for hybrid pipelines alongside pure vector and lexical docs
- Best practices and limitations section for production hybrid pipelines
- Cross-links to vector-search and lexical-search companion guides for pure-mode setup
Adoption & trust: 1.2k installs on skills.sh; 131 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need both semantic and keyword recall in one ranked result set but only know isolated `$vectorSearch` or lexical `$search` examples.
Who is it for?
Indie builders adding RAG, marketplace search, or support KB lookup on Atlas with explicit fusion tradeoffs.
Skip if: Teams on self-hosted MongoDB without Atlas Search, or apps that only need a single-mode lexical or vector index with no merging.
When should I use this skill?
You are implementing Atlas hybrid search and must pick fusion vs prefilter approaches on a single collection.
What do I get? / Deliverables
After running the skill, your agent can choose a fusion or prefilter pattern, shape indexes for hybrid pipelines, and draft aggregation stages aligned with Atlas Search limits.
- Hybrid search aggregation pipeline draft (`$rankFusion`, `$scoreFusion`, or prefiltered `$search`)
- Indexing notes aligned with hybrid vs pure vector/lexical guides
Recommended Skills
Journey fit
Search index design and aggregation pipelines are core backend build work once you have a MongoDB-backed app. Atlas `$search`, `$vectorSearch`, `$rankFusion`, and `$scoreFusion` are integration patterns against MongoDB Atlas, not generic frontend UI.
How it compares
Skill package for Atlas aggregation patterns—not a vector DB MCP server and not a one-click search SaaS.
Common Questions / FAQ
Who is mongodb-search-and-ai for?
Solo and indie developers building search or AI features on MongoDB Atlas who want agent-guided hybrid pipeline design.
When should I use mongodb-search-and-ai?
During Build when designing Atlas Search stages—e.g. merging vector and text rankings for a SaaS catalog, or prefiltering embeddings with compound lexical clauses before `$vectorSearch`.
Is mongodb-search-and-ai safe to install?
Review the Security Audits panel on this Prism page and the upstream mongodb/agent-skills repo before granting network or secrets access in your agent.
SKILL.md
READMESKILL.md - Mongodb Search And Ai
# Hybrid Search This guide covers hybrid search patterns in MongoDB Atlas: combining vector and lexical search using `$rankFusion` and `$scoreFusion`, and using lexical prefilters with the `vectorSearch` operator inside `$search`. **Scope**: This guide covers hybrid pipelines. For pure vector search indexes and `$vectorSearch` query construction, see vector-search.md. For lexical index definitions and query patterns, see lexical-search-indexing.md and lexical-search-querying.md. ## Table of Contents - [Overview](#overview) - [Choosing the Right Approach](#choosing-the-right-approach) - [Indexing for Hybrid Search](#indexing-for-hybrid-search) - [$rankFusion](#rankfusion) - [$scoreFusion](#scorefusion) - [Lexical Prefilters (vectorSearch Operator)](#lexical-prefilters-vectorsearch-operator) - [Best Practices and Limitations](#best-practices-and-limitations) --- ## Overview Hybrid search combines multiple search methods on the same collection and merges the results into a single ranked or scored list. **Three patterns covered in this guide:** | Pattern | Stage / Operator | Use When | |---|---|---| | Rank-based fusion | `$rankFusion` | Document position matters; use RRF algorithm | | Score-based fusion | `$scoreFusion` | Score magnitude matters; need custom math or normalization | | Lexical prefilter | `$search` + `vectorSearch` operator | Need fuzzy/phrase/wildcard/compound pre-filtering before vector search | **$rankFusion vs $scoreFusion:** - `$rankFusion` ranks by position in each input pipeline using the Reciprocal Rank Fusion (RRF) algorithm. A document ranked #1 in multiple pipelines scores much higher than one ranked #1 in only one. Weights influence how much each pipeline's rank contributes. - `$scoreFusion` ranks by the actual score values from each pipeline. Supports normalization (sigmoid, minMaxScaler) and custom combination expressions. Use when score magnitude, not just ordering, matters. --- ## Choosing the Right Approach | Scenario | Recommended Approach | |---|---| | Combine lexical + vector, rank by position | `$rankFusion` | | Combine lexical + vector, control score math or normalization | `$scoreFusion` | | Multiple query vectors or embedding models on same collection | `$rankFusion` with multiple `$vectorSearch` pipelines | | Pre-filter vector search with fuzzy, phrase, wildcard, or compound | `$search` + `vectorSearch` operator | | Pre-filter vector search with simple equality or range | `filter` fields in `$vectorSearch` (see vector-search.md) | | Cross-collection hybrid search | `$unionWith` + `$vectorSearch` (not `$rankFusion`/`$scoreFusion`) | **Version requirements**: `$rankFusion` requires MongoDB 8.0+. `$scoreFusion` requires MongoDB 8.2+. Only proceed with this guide if the use case is lexical prefilters, or if the cluster meets the version requirement for the fusion stage of interest. Otherwise do not proceed. --- ## Indexing for Hybrid Search ### For $rankFusion and $scoreFusion You need two separate indexes on the collection: **1. A vectorSearch-type index** for the `$vectorSearch` input pipeline: ```javascript db.collection.createSearchIndex( "<vector-index-name>", "vectorSearch", { "fields": [ { "type": "vector", "path": "<embedding-field>", "numDimensions": <number>, "similarity": "dotProduct" } ] } ) ``` **2. A search-type index** for the `$search` input pipeline: ```javascript db.collection.createSearchIndex( "<search-index-name>", { "mappings": { "dynamic": true } } ) ``` --- ### For Lexical Prefilters (vectorSearch Operator) The `vectorSearch` operator runs inside `$search`, so you need a **single search-type index** that includes a `vector` field type. This is different from a vectorSearch-type index — you cannot use the `$vectorSearch` stage to query fields indexed this way. ```javascript db.collection.createSearchIndex( "<search-index-name>", { "mappings": { "dynamic": true,