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
Easy start for AI teams
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.
{
_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
Compare a typical AI setup against what DocumentDB consolidates into one system.
Easy start
Everything runs on your machine: DocumentDB in Docker, an open embedding model in Ollama, and a short Python script.
Docker
One command starts DocumentDB on port 10260 with local credentials.
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
Shell
Ollama runs an open embedding model on your machine, so your text never leaves it. Any model works; size the index to its output.
Python: store
Embed each note, store it next to its text, and add an HNSW vector index with cosine similarity.
Python: search
Add this to the same script. It embeds the question and returns the closest notes with their similarity scores.
Use cases
Vector retrieval, document storage, and query power in one system — ready for the patterns teams are actually shipping.
Store chunks, metadata, and embeddings together so retrieval stays close to the source document.
Search products, knowledge bases, or support histories by meaning instead of exact keyword match.
Store conversation state as BSON documents and retrieve past context with vector similarity.
Find the best vector matches, then traverse related entities with $graphLookup in one query pipeline.
Samples
Each sample is a complete app that stores its embeddings in DocumentDB and queries them with a standard Mongo driver.
AI/ML
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.
AI/ML
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.
AI/ML
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'.
Financial Services
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.
Media & Publishing
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.
Healthcare
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.
Retail
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'.
For coding agents
Public previewAgent-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.
Go from zero to vector search in four steps. Open source, self-hosted, MIT-licensed.