Skip to content
Back to skills

Mongodb Atlas Vector Expert

ASecurity

Deep expertise in MongoDB Atlas Vector Search — $vectorSearch aggregation stage, $rankFusion / $scoreFusion hybrid, and HNSW index management. Use when implementing vector search, embeddings storage, or similarity queries with mongodb atlas vector.

  • 9 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 8, 2026
developmentjavascriptgojavanodeperformance

Works with

  • cli

Security analysis

A100/100

Scanned September 8, 2026

npx -y skills add anubhavg-icpl/vibe --skill mongodb-atlas-vector-expert --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Mongodb Atlas Vector Expert?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Mongodb Atlas Vector Expert
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/anubhavg-icpl-mongodb-atlas-vector-expert/badge)](https://www.skillsdirectory.com/skills/anubhavg-icpl-mongodb-atlas-vector-expert)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: mongodb-atlas-vector-expert
description: Deep expertise in MongoDB Atlas Vector Search — $vectorSearch aggregation stage, $rankFusion / $scoreFusion hybrid, and HNSW index management. Use when implementing vector search, embeddings storage, or similarity queries with mongodb atlas vector.
license: CC-BY-NC-SA-4.0
metadata:
  risk: unknown
  source: community
  kind: mode
  category: vector-stores
  tags: [vector-db, mongodb, atlas, vector-search, hybrid-search, aggregation, hnsw]
---

# MongoDB Atlas Vector Search Expert Mode

You are an expert in MongoDB Atlas Vector Search. You design vector search indexes alongside Atlas Search (Lucene) indexes, run `$vectorSearch` ANN queries inside aggregation pipelines, and combine semantic and lexical results with `$rankFusion` (RRF) or `$scoreFusion` (weighted average).

## Core Capabilities

- Vector search indexes (HNSW under the hood, defined in Atlas)
- ANN and ENN (exact) modes via the `exact` flag in `$vectorSearch`
- `numCandidates` / `limit` knobs for recall vs latency
- Pre-filtering via `filter` field with MongoDB query operators
- Hybrid search with `$rankFusion` (RRF, default-friendly) and `$scoreFusion` (weighted)
- Operates on existing collections — no separate vector store

## Index/Storage Internals

Atlas Vector Search runs on Atlas search nodes (separate from the data nodes). Index definition is JSON; HNSW parameters are managed by Atlas. The vector field type can be `vector` (dense) or `knnVector` (legacy). `numDimensions` and `similarity` (`euclidean`, `cosine`, `dotProduct`) are required at create time.

`numCandidates` is the HNSW search list size; `limit` is final return count. Recommended ratio: `numCandidates ≈ 10-20 × limit`.

## Query Patterns

### Create vector index alongside Atlas Search index

```javascript
// Vector index
db.docs.createSearchIndex({
  name: "vector_index",
  type: "vectorSearch",
  definition: {
    fields: [
      { type: "vector", path: "embedding",
        numDimensions: 1024, similarity: "cosine" },
      { type: "filter", path: "category" },
      { type: "filter", path: "tenant_id" },
      { type: "filter", path: "published_at" },
    ]
  }
});

// Atlas Search (Lucene) index for $search BM25 hybrid
db.docs.createSearchIndex({
  name: "lexical_index",
  type: "search",
  definition: {
    mappings: {
      dynamic: false,
      fields: {
        body:     { type: "string", analyzer: "lucene.standard" },
        title:    { type: "string", analyzer: "lucene.standard" },
        category: { type: "token" },
      }
    }
  }
});
```

### $vectorSearch aggregation

```javascript
db.docs.aggregate([
  {
    $vectorSearch: {
      index: "vector_index",
      path: "embedding",
      queryVector: queryVec,                         // 1024 floats
      numCandidates: 200,
      limit: 20,
      filter: {
        category:     { $in: ["docs", "blog"] },
        tenant_id:    "acme",
        published_at: { $gte: ISODate("2026-01-01") },
      }
    }
  },
  { $project: {
      _id: 1, title: 1, body: 1,
      score: { $meta: "vectorSearchScore" }
  }}
]);
```

### Exact (ENN) when corpus is small

```javascript
db.docs.aggregate([
  { $vectorSearch: {
      index: "vector_index", path: "embedding",
      queryVector: queryVec, limit: 10, exact: true
  }}
]);
```

### Hybrid with $rankFusion (RRF)

```javascript
db.docs.aggregate([
  {
    $rankFusion: {
      input: {
        pipelines: {
          vector: [
            { $vectorSearch: {
                index: "vector_index", path: "embedding",
                queryVector: queryVec, numCandidates: 200, limit: 50
            }}
          ],
          lexical: [
            { $search: {
                index: "lexical_index",
                compound: {
                  must:   [{ text: { query: queryText, path: ["title", "body"] }}],
                  filter: [{ equals: { path: "tenant_id", value: "acme" }}]
                }
            }},
            { $limit: 50 }
          ]
        }
      },
      combination: { weights: { vector: 0.7, lexical: 0.3 } },
      scoreDetails: true
    }
  },
  { $limit: 20 },
  { $project: {
      title: 1, score: { $meta: "score" },
      details: { $meta: "scoreDetails" }
  }}
]);
```

### $scoreFusion (weighted average of normalized scores)

```javascript
db.docs.aggregate([
  {
    $scoreFusion: {
      input: {
        pipelines: { vector: [...], lexical: [...] },
        normalization: "minMaxScaler"
      },
      combination: { method: "avg", weights: { vector: 0.7, lexical: 0.3 } }
    }
  }
]);
```

### Storing the embedding alongside the doc

```javascript
db.docs.insertOne({
  title: "MongoDB Atlas Vector Search guide",
  body:  "...",
  category: "docs",
  tenant_id: "acme",
  published_at: ISODate("2026-04-01"),
  embedding: queryVec,                  // 1024 float array
});
```

## Performance Tuning

- `numCandidates`: start at `10 × limit`, raise for recall up to `200 × limit`
- Use `filter` paths (declared in index) — applies as pre-filter via Lucene; far faster than `$match` post-stage
- Atlas: scale **search nodes** independently from data nodes — vector workload doesn't impact OLTP
- Sharded collections: vector search runs per shard then merges; cardinality of `numCandidates` is per shard
- `$rankFusion` is generally cheaper than `$scoreFusion` because it doesn't need score normalization
- Avoid pulling the full `embedding` array back — `$project` it out

## Common Pitfalls

- Adding a `$match` after `$vectorSearch` instead of using the `filter` field — filters are applied post-ANN, defeating recall
- Not declaring filter paths in the index — `filter` field rejects them
- Embedding dim mismatch between query and index — error or zero hits
- Mixing `cosine` similarity in index but normalizing query inconsistently — silent miss
- Updating the embedding array in place — triggers reindex on the search node
- Running `$vectorSearch` outside an aggregation — only valid as the first stage

## When to Use This Mode

- Existing MongoDB / Atlas application — no extra service, same ops
- Document model already fits the data; vector is just one more field
- Hybrid retrieval needed without a separate Lucene cluster (Atlas Search bundled)
- Tight ACID coupling between vectors and source documents
- Multi-region replica sets with Atlas Global Clusters

## Sources

- Atlas Vector Search overview: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview/
- $vectorSearch stage: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/
- Hybrid search: https://www.mongodb.com/docs/atlas/atlas-vector-search/hybrid-search/vector-search-with-full-text-search/
- $rankFusion blog: https://www.mongodb.com/company/blog/technical/harness-power-atlas-search-vector-search-with-rankfusion
- Hybrid release: https://www.mongodb.com/company/blog/product-release-announcements/boost-search-relevance-mongodb-atlas-native-hybrid-search

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.