Quick Start
This tutorial walks you through creating your first QMD index, adding documents, and performing searches. You’ll have a working search engine for your markdown files in minutes.This guide assumes you’ve already installed QMD. If not, install it first with
npm install -g @tobilu/qmd or bun install -g @tobilu/qmd.Step 1: Create Your First Collection
Collections tell QMD which directories to index and what files to include.Choose a directory
Pick a directory with markdown files to index. For this example, we’ll use a notes directory:Or index the current directory:
By default, QMD indexes all
**/*.md files (markdown files recursively). You can customize this with the --mask flag.Add Multiple Collections
Organize different types of documents into separate collections:Custom Glob Patterns
Control which files are indexed with the--mask flag:
Step 2: Add Context (Optional but Recommended)
Context helps QMD understand your documents and returns descriptive metadata with search results. This is especially useful for AI agents.Add collection-level context
Add a description for each collection:The
qmd:// prefix indicates a virtual path to a collection.Step 3: Generate Embeddings
Embeddings enable semantic search and are required forvsearch and query commands.
- Downloads the embedding model (~300MB) if not already cached
- Chunks documents into ~900-token pieces with smart boundary detection
- Generates embeddings for each chunk
- Stores vectors in the SQLite index
The first run downloads the
embeddinggemma-300M-Q8_0 model (~300MB). Subsequent runs use the cached model.Embedding Progress
QMD shows progress as it embeds documents:Re-embedding
QMD automatically embeds new or changed documents. To force re-embedding everything:Step 4: Search Your Documents
QMD provides three search modes. Let’s try each one.- query (Hybrid)
- search (BM25)
- vsearch (Vector)
Hybrid Search (Recommended)
Combines BM25, vector search, query expansion, and LLM re-ranking for the best results:This mode downloads two additional models on first use:
qwen3-reranker-0.6b-q8_0 (~640MB) and qmd-query-expansion-1.7B-q4_k_m (~1.1GB).Search Options
Step 5: Retrieve Documents
Once you’ve found relevant documents, retrieve them by path or docid.Get by File Path
Get by Document ID
Every document has a 6-character docid (shown in search results as#abc123):
# prefix is optional:
Get Multiple Documents
Retrieve multiple documents with glob patterns or comma-separated lists:Step 6: Output Formats for AI Agents
QMD provides multiple output formats optimized for AI agents and scripting.- JSON
- Files
- Markdown
Step 7: Check Index Status
View index statistics and health:Common Workflows
Daily Update
Update the index with new/changed files:Search and Open
Find a document and open it in your editor:Export for LLM Context
Get all relevant documents above a score threshold:context.md as context for your LLM.
Collection Management
Next Steps
MCP Integration
Connect QMD to Claude Desktop, Claude Code, or custom MCP clients
Search Modes
Learn about BM25, vector search, and hybrid query modes
Collection Management
Advanced collection configuration and context management
CLI Reference
Complete command-line reference with all options and flags
Troubleshooting
No search results
No search results
Possible causes:
- Collection not indexed: Run
qmd updateto index files - Files not matched by glob: Check collection pattern with
qmd collection list - Score too low: Try lowering
--min-scoreor increase-n - Embeddings missing: Run
qmd embedfor vector/hybrid search
Search is slow
Search is slow
Solutions:
- Use
search(BM25 only) instead ofqueryfor faster results - Filter by collection with
-c <name>to reduce search space - Reduce number of results with
-n <num> - Check index health with
qmd statusand clean up withqmd cleanup
Embeddings fail
Embeddings fail
Error:
Failed to load embedding modelSolutions:- Check internet connection (models download from HuggingFace)
- Verify sufficient disk space (~300MB for embedding model)
- Try manual download (see Installation)
- Check
~/.cache/qmd/models/for corrupted downloads
Collection path not found
Collection path not found
Error:
Collection path does not existSolutions:- Use absolute paths:
qmd collection add ~/Documents/notes --name notes - Verify the directory exists:
ls ~/Documents/notes - Check for typos in the path