NewDocumentDB 1.0 is here. See what's new

Easy start for AI teams

Stop juggling databases for AI

Documents, vectors, and search in one Mongo API-compatible system.

Run locally with Docker, use familiar Mongo drivers and tools, and keep documents plus embeddings together — no extra sync layer needed.

Start locally in minutesMongo API-compatibleNative vector searchMIT licensed
One documentNo second database

Your text, its metadata, and its embedding live together

{
  _id: "handbook-chunk-42",
  text: "Keep each chunk next to its embedding...",
  source: "handbook.pdf",
  embedding: [0.0213, -0.0871, 0.0456, /* ...768 numbers */]
}

A single $vectorSearch stage finds the nearest embeddings and returns the documents they belong to.

API

Mongo API-compatible

Use familiar Mongo drivers and tools.

Indexing

HNSW + IVFFlat

Choose the right vector algorithm for recall, scale, and cost.

Retrieval

Vector search

Filter by metadata and return similarity scores.

Why teams choose it

A simpler stack for AI

Compare a typical AI setup against what DocumentDB consolidates into one system.

Before

Typical AI stack

  • App database for documents and metadata
  • Separate vector database for embeddings
  • Extra data sync and failure modes between systems
  • More moving parts, more cost, more things to break
After

DocumentDB stack

  • BSON documents and embeddings stored together
  • Native vector search with filtering in one database
  • Geospatial, graph, and 40+ aggregation stages in one system
  • Simpler architecture with PostgreSQL-backed operations

Easy start

Go from zero to vector search in four steps

Everything runs on your machine: DocumentDB in Docker, an open embedding model in Ollama, and a short Python script.

01

Docker

Run DocumentDB

One command starts DocumentDB on port 10260 with local credentials.

Docker

docker run -dt --pull always --name documentdb \
  -p 127.0.0.1:10260:10260 \
  -e USERNAME=admin \
  -e PASSWORD=password \
  ghcr.io/documentdb/documentdb/documentdb-local:latest

The image sends usage telemetry by default. Add -e DOCUMENTDB_USAGE_TELEMETRY=false before the image name to turn it off. What is sent · Privacy statement

02

Shell

Get an embedding model

Ollama runs an open embedding model on your machine, so your text never leaves it. Any model works; size the index to its output.

Shell

ollama pull nomic-embed-text
pip install pymongo ollama
Download Ollama
03

Python: store

Store text with its embedding

Embed each note, store it next to its text, and add an HNSW vector index with cosine similarity.

Python: store

import ollama
from pymongo import MongoClient

client = MongoClient("mongodb://admin:password@localhost:10260/?tls=true&tlsAllowInvalidCertificates=true")
db = client.demo

def embed(text):
    return ollama.embed(model="nomic-embed-text", input=text)["embeddings"][0]

notes = [
    "DocumentDB is an open-source document database built on PostgreSQL.",
    "Our office is closed on public holidays.",
    "Keep each text chunk next to its embedding so retrieval returns the source.",
]
db.notes.insert_many([{"text": t, "embedding": embed(t)} for t in notes])

db.command({
    "createIndexes": "notes",
    "indexes": [{
        "key": {"embedding": "cosmosSearch"},
        "name": "vector_idx",
        "cosmosSearchOptions": {
            "kind": "vector-hnsw",
            "similarity": "COS",
            "dimensions": 768,  # nomic-embed-text output size
        },
    }],
})
createIndexes reference
04

Python: search

Ask a question

Add this to the same script. It embeds the question and returns the closest notes with their similarity scores.

Python: search

question = "Which database runs on Postgres?"
results = db.notes.aggregate([
    {"$vectorSearch": {"queryVector": embed(question), "path": "embedding", "limit": 2}},
    {"$project": {"_id": 0, "text": 1, "score": {"$meta": "searchScore"}}},
])
for note in results:
    print(f"{note['score']:.2f}  {note['text']}")
$vectorSearch reference

Use cases

Built for the AI workloads that matter

Vector retrieval, document storage, and query power in one system — ready for the patterns teams are actually shipping.

RAG

RAG and grounded chat

Store chunks, metadata, and embeddings together so retrieval stays close to the source document.

  • Pre-filter by category, source, or recency before retrieval
  • Return source text alongside similarity scores
Sample: Hotel Recommendation Agent
Search

Semantic search

Search products, knowledge bases, or support histories by meaning instead of exact keyword match.

  • Choose cosine, L2, or inner product for your domain
  • Mix vector results with metadata filters in one query
Sample: Content Semantic Search Portal
Agents

Agent memory

Store conversation state as BSON documents and retrieve past context with vector similarity.

  • Persist tool outputs, plans, and dialogue turns naturally
  • Recall relevant history without scanning entire threads
Sample: Personal AI Memory
Graph + AI

Knowledge navigation

Find the best vector matches, then traverse related entities with $graphLookup in one query pipeline.

  • Recursive traversal with depth control
  • Useful when retrieval also needs relationship traversal
$graphLookup reference

Samples

AI apps you can clone and run

Each sample is a complete app that stores its embeddings in DocumentDB and queries them with a standard Mongo driver.

Built withLlamaIndexOllamaOpenAIMCP
𝗧𝗦
TypeScript

AI/ML

Intermediate

Personal AI Memory: Cross-Platform MCP Server with DocumentDB Vector Search

A TypeScript MCP server that gives any AI assistant — Copilot CLI, Claude, Gemini — persistent personalized memory backed by DocumentDB. Uses a 4-layer retrieval strategy: cosmosSearch vector similarity, full-text search indexes, array tag queries, and regex fallback. Demonstrates DocumentDB's vector search (pgvector), MongoDB wire protocol compatibility, text indexes, atomic update operators, and flexible document schema in a practical AI application.

MCPAI MemoryVector SearchFull-Text SearchText IndexExpressRAGDocumentDB OSSOpen Source
View on GitHub
𝗧𝗦
TypeScript

AI/ML

Intermediate

Hotel Recommendation Agent: RAG with Native Vector Search and LLM Synthesizer in TypeScript

A TypeScript app that uses DocumentDB OSS native vector search to retrieve semantically similar hotels from a natural-language query, then passes the results to a LlamaIndex synthesizer agent (llama3.2 via Ollama) to generate a concise, comparative recommendation. Runs entirely on open-source tools with no cloud accounts required.

Vector SearchAI AgentLlamaIndexOllamaEmbeddingsRAGDocumentDB OSSOpen Source
View on GitHub
⬡
Node.js

AI/ML

Intermediate

BookFinder: AI-Powered Semantic Book Discovery

A Node.js/Express app that uses OpenAI embeddings and DocumentDB vector search to let users discover books through natural language queries like 'dystopian future with rebellion'.

Vector SearchOpenAIEmbeddingsExpressSemantic Search
View on GitHub
🐍
Python

Financial Services

Intermediate

Fraud Detection Multi-Agent System: Retrieval, Analysis, and Decision Agents with DocumentDB Vector Search

A Python app that uses a three-agent pipeline — Retrieval, Analysis, and Decision — to classify transactions as APPROVE, REVIEW, or BLOCK. The Retrieval Agent finds similar historical transactions using DocumentDB OSS native vector search; the Analysis Agent uses llama3.2 via Ollama to identify risk patterns; the Decision Agent issues the final verdict with a confidence score. Runs entirely on open-source tools with no cloud accounts required.

Vector SearchMulti-AgentFraud DetectionOllamaEmbeddingsRAGDocumentDB OSSOpen Source
View on GitHub
🐍
Python

Media & Publishing

Beginner

Content Semantic Search Portal: Semantic Search Over Articles, Blogs, and PDFs

A Python/Flask web portal that stores articles, blogs, and PDF documents as MongoDB documents with vector embeddings in DocumentDB OSS. Users search by meaning using natural language and receive semantically ranked results by cosine similarity. Supports ingesting custom .txt and .pdf files alongside sample content. Built entirely on open-source tools with no cloud accounts required.

Vector SearchSemantic SearchFlaskEmbeddingsOllamaPDFDocumentDB OSSOpen Source
View on GitHub
🐍
Python

Healthcare

Intermediate

Clinical Note Similarity Explorer: Find Similar Cases with DocumentDB Vector Search

A Python/Flask web app that stores de-identified fictional clinical notes with vector embeddings and metadata in DocumentDB OSS. Clinicians and researchers can search for similar cases using natural language clinical descriptions, filtered by medical specialty, with results ranked by semantic similarity. All notes are fictional sample data. Built entirely on open-source tools.

Vector SearchSemantic SearchFlaskEmbeddingsOllamaClinical NLPDocumentDB OSSOpen Source
View on GitHub
𝗧𝗦
TypeScript

Retail

Intermediate

Contoso Retail: Hybrid Cloud/Edge Store with Live DB Switching, Replication, and Vector Search

A TypeScript/Express retail application that runs the same code against Azure DocumentDB (managed cloud) and OSS DocumentDB (local containers) — switchable in real time from the UI. Features product catalog with vector similarity recommendations (Ollama + nomic-embed-text), inventory management across 3 warehouses, order processing with sync-to-Azure, and live hybrid replication with animated latency visualization. Built for the talk: 'One Codebase, Any Cloud: Building a Retail Database with OSS and Azure DocumentDB'.

Vector SearchHybrid CloudReplicationExpressOllamaEmbeddingsDocumentDB OSSAzure DocumentDBDockerFull Stack
View on GitHub
Browse all samples

For coding agents

Public preview

Teach your coding agent DocumentDB

Agent-Kit gives Claude Code, Cursor, Codex, Gemini CLI, and GitHub Copilot skills for data modeling, indexing, and vector search, an MCP server, and read-only diagnostics for a local DocumentDB container.

Get Agent-Kit on GitHub

Ready to try it?

Go from zero to vector search in four steps. Open source, self-hosted, MIT-licensed.