QMD provides powerful document retrieval commands that work with paths, docids, and glob patterns.
Single Document Retrieval
Get by Path
Retrieve a document using its path (relative to collection):
Get by Docid
Every document has a unique short identifier (docid) - the first 6 characters of its content hash. Docids appear in search results:
qmd search "authentication"
Output shows docids:
docs/auth-guide.md:42 #a1b2c3
Title: Authentication Guide
Score: 93%
...
Retrieve using docid:
Docids are stable as long as the document content doesn’t change. If content changes, a new hash (and docid) is generated.
Start at Specific Line
Retrieve from a specific line number:
qmd get notes/meeting.md:50
Limit the number of lines returned:
# Get 100 lines starting from line 50
qmd get notes/meeting.md:50 -l 100
Add Line Numbers
qmd get notes/meeting.md --line-numbers
Output:
1: # Meeting Notes - 2025-01-15
2:
3: ## Attendees
4: - Alice, Bob, Carol
5:
6: ## Topics
...
Fuzzy Matching
QMD suggests similar files if exact match fails:
Output:
Document not found: meetting.md
Did you mean one of these?
- notes/meeting.md
- notes/meeting-2025-01-14.md
- work/team-meeting.md
Multiple Document Retrieval
Multi-Get by Glob Pattern
Retrieve multiple documents matching a pattern:
qmd multi-get "meetings/2025-01-*.md"
Example output:
============================================================
File: meetings/2025-01-10.md
============================================================
# Team Standup - Jan 10
## Updates
...
============================================================
File: meetings/2025-01-15.md
============================================================
# Weekly Sync - Jan 15
## Action Items
...
Multi-Get by Comma-Separated List
Retrieve specific files (supports docids):
qmd multi-get "doc1.md, doc2.md, #abc123"
Size Limits
By default, multi-get skips files larger than 10KB. Adjust with --max-bytes:
qmd multi-get "docs/*.md" --max-bytes 20480
Skipped files show a message:
[SKIPPED: File too large (45KB > 10KB). Use 'qmd get docs/large-file.md' to retrieve.]
Line Limits
Limit lines per file:
qmd multi-get "journals/2025-*.md" -l 50
Truncated files show:
...
[... truncated 127 more lines]
multi-get supports the same formats as search:
CLI (default)
JSON
CSV
Markdown
XML
Files List
qmd multi-get "notes/2025-01-*.md"
Displays each file with headers and separators.qmd multi-get --json "journals/2025-05*.md"
[
{
"file": "journals/2025-05-01.md",
"title": "Daily Journal - May 1",
"context": "Personal journals",
"body": "# May 1, 2025\n\nToday I..."
},
{
"file": "journals/large-file.md",
"title": "Archive",
"skipped": true,
"reason": "File too large (45KB > 10KB)"
}
]
qmd multi-get --csv "docs/*.md" > documents.csv
file,title,context,skipped,body
docs/api.md,API Guide,Work documentation,false,"# API Guide..."
qmd multi-get --md "notes/*.md" > combined.md
## notes/meeting.md
**Title:** Team Meeting
**Context:** Work notes
\`\`\`
# Meeting Notes
...
\`\`\`
qmd multi-get --xml "docs/*.md"
<?xml version="1.0" encoding="UTF-8"?>
<documents>
<document>
<file>docs/api.md</file>
<title>API Guide</title>
<context>Work documentation</context>
<body># API Guide...</body>
</document>
</documents>
qmd multi-get --files "notes/*.md"
notes/meeting.md,"Work notes"
notes/ideas.md,"Personal notes"
notes/large.md,"Personal notes",[SKIPPED]
Context in Retrieved Documents
Retrieved documents include context metadata when configured:
qmd get notes/work/meeting.md
Output:
Folder Context: Work-related notes
---
# Team Meeting - Jan 15
## Attendees
...
See Context Management for details on adding context.
Use Cases
Export LLM Context
Gather all relevant documents for an AI agent:
qmd search --files --all --min-score 0.4 "authentication" > files.txt
cat files.txt | cut -d, -f1 | xargs -I {} qmd get {} > context.md
Or use multi-get directly:
qmd multi-get "docs/auth-*.md" --md --full > llm-context.md
Batch Processing
Process multiple documents with a script:
qmd multi-get --json "journals/2025-*.md" | jq -r '.[] | .file + ": " + .title'
Archive to Single File
Combine all documents in a directory:
qmd multi-get "notes/2024/**/*.md" --md > archive-2024.md
Selective Retrieval
Get only small files for quick processing:
qmd multi-get "docs/*.md" --max-bytes 5120 --json
Working with Docids
In Search Results
Docids appear in all search output formats:
qmd search "API"
# docs/api.md:10 #a1b2c3
In Multi-Get
Mix docids with paths:
qmd multi-get "#a1b2c3, notes/meeting.md, #def456"
Stability
Docids are content-based:
- Unchanged content = same docid across re-indexes
- Modified content = new docid (old one becomes invalid)
- Moved files = same docid (based on content, not path)
Use Glob Patterns
multi-get with globs is faster than individual get calls in a loop.
Set Size Limits
Use --max-bytes to skip large files when you only need metadata or summaries.
Limit Lines
-l 100 retrieves only the first 100 lines, reducing I/O for large documents.
Use Docids for Stability
Docids work even if files are moved or renamed (as long as content is unchanged).