Skip to main content
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):
qmd get notes/meeting.md

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:
qmd get "#a1b2c3"
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:
qmd get meetting.md
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]

Output Formats

multi-get supports the same formats as search:
qmd multi-get "notes/2025-01-*.md"
Displays each file with headers and separators.

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)

Performance Tips

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).

Build docs developers (and LLMs) love