qmd - Quick Markdown Search
Local search engine for Markdown notes, docs, and knowledge bases. Index once, search fast.
When to use (trigger phrases)
- - "search my notes / docs / knowledge base"
- "find related notes"
- "retrieve a markdown document from my collection"
- "search local markdown files"
Default behavior (important)
- - Prefer
qmd search (BM25). It's typically instant and should be the default. - Use
qmd vsearch only when keyword search fails and you need semantic similarity (can be very slow on a cold start). - Avoid
qmd query unless the user explicitly wants the highest quality hybrid results and can tolerate long runtimes/timeouts.
Prerequisites
- - Bun >= 1.0.0
- macOS:
brew install sqlite (SQLite extensions) - Ensure PATH includes: INLINECODE4
Install Bun (macOS): INLINECODE5
Install
INLINECODE6
Setup
CODEBLOCK0
What it indexes
- - Intended for Markdown collections (commonly
**/*.md). - In our testing, "messy" Markdown is fine: chunking is content-based (roughly a few hundred tokens per chunk), not strict heading/structure based.
- Not a replacement for code search; use code search tools for repositories/source trees.
Search modes
- -
qmd search (default): fast keyword match (BM25) - INLINECODE9 (last resort): semantic similarity (vector). Often slow due to local LLM work before the vector lookup.
- INLINECODE10 (generally skip): hybrid search + LLM reranking. Often slower than
vsearch and may timeout.
Performance notes
- -
qmd search is typically instant. - INLINECODE13 can be ~1 minute on some machines because query expansion may load a local model (e.g., Qwen3-1.7B) into memory per run; the vector lookup itself is usually fast.
- INLINECODE14 adds LLM reranking on top of
vsearch, so it can be even slower and less reliable for interactive use. - If you need repeated semantic searches, consider keeping the process/model warm (e.g., a long-lived qmd/MCP server mode if available in your setup) rather than invoking a cold-start LLM each time.
Common commands
CODEBLOCK1
Useful options
- -
-n <num>: number of results - INLINECODE17 : restrict to a collection
- INLINECODE18 : return all matches above a threshold
- INLINECODE19 /
--files: agent-friendly output formats - INLINECODE21 : return full document content
Retrieve
CODEBLOCK2
Maintenance
CODEBLOCK3
Keeping the index fresh
Automate indexing so results stay current as you add/edit notes.
- - For keyword search (
qmd search), qmd update is usually enough (fast). - If you rely on semantic/hybrid search (
vsearch/query), you may also want qmd embed, but it can be slow.
Example schedules (cron):
CODEBLOCK4
If your Clawdbot/agent environment supports a built-in scheduler, you can run the same commands there instead of system cron.
Models and cache
- - Uses local GGUF models; first run auto-downloads them.
- Default cache:
~/.cache/qmd/models/ (override with XDG_CACHE_HOME).
Relationship to Clawdbot memory search
- -
qmd searches your local files (notes/docs) that you explicitly index into collections. - Clawdbot's
memory_search searches agent memory (saved facts/context from prior interactions). - Use both:
memory_search for "what did we decide/learn before?", qmd for "what's in my notes/docs on disk?".
qmd - 快速Markdown搜索
用于Markdown笔记、文档和知识库的本地搜索引擎。一次索引,快速搜索。
使用时机(触发短语)
- - 搜索我的笔记/文档/知识库
- 查找相关笔记
- 从我的收藏中检索Markdown文档
- 搜索本地Markdown文件
默认行为(重要)
- - 优先使用qmd search(BM25)。通常即时响应,应为默认选项。
- 仅在关键词搜索失败且需要语义相似度时使用qmd vsearch(冷启动时可能非常慢)。
- 除非用户明确要求最高质量的混合结果并能容忍长时间运行/超时,否则避免使用qmd query。
前置条件
- - Bun >= 1.0.0
- macOS:brew install sqlite(SQLite扩展)
- 确保PATH包含:$HOME/.bun/bin
安装Bun(macOS):brew install oven-sh/bun/bun
安装
bun install -g https://github.com/tobi/qmd
设置
bash
qmd collection add /path/to/notes --name notes --mask /*.md
qmd context add qmd://notes 该集合的描述 # 可选
qmd embed # 一次性操作,启用向量和混合搜索
索引内容
- - 适用于Markdown集合(通常为/*.md)。
- 在我们的测试中,杂乱的Markdown也可以:分块基于内容(每块约几百个token),而非严格的标题/结构。
- 不能替代代码搜索;代码搜索请使用专门的代码搜索工具。
搜索模式
- - qmd search(默认):快速关键词匹配(BM25)
- qmd vsearch(最后手段):语义相似度(向量)。由于向量查找前需要本地LLM工作,通常较慢。
- qmd query(通常跳过):混合搜索 + LLM重排序。通常比vsearch更慢,可能超时。
性能说明
- - qmd search通常即时响应。
- qmd vsearch在某些机器上可能需要约1分钟,因为查询扩展可能每次运行都会将本地模型(如Qwen3-1.7B)加载到内存;向量查找本身通常很快。
- qmd query在vsearch基础上增加了LLM重排序,因此交互使用时可能更慢且更不可靠。
- 如果需要重复进行语义搜索,建议保持进程/模型预热(例如,如果环境支持,使用长驻的qmd/MCP服务器模式),而不是每次冷启动LLM。
常用命令
bash
qmd search 查询内容 # 默认
qmd vsearch 查询内容
qmd query 查询内容
qmd search 查询内容 -c notes # 搜索特定集合
qmd search 查询内容 -n 10 # 更多结果
qmd search 查询内容 --json # JSON输出
qmd search 查询内容 --all --files --min-score 0.3
实用选项
- - -n :结果数量
- -c, --collection :限定集合范围
- --all --min-score :返回所有超过阈值的结果
- --json / --files:适合代理的输出格式
- --full:返回完整文档内容
检索
bash
qmd get path/to/file.md # 完整文档
qmd get #docid # 通过搜索结果中的ID
qmd multi-get journals/2025-05*.md
qmd multi-get doc1.md, doc2.md, #abc123 --json
维护
bash
qmd status # 索引健康检查
qmd update # 重新索引变更的文件
qmd embed # 更新嵌入向量
保持索引更新
自动化索引,确保在添加/编辑笔记时结果保持最新。
- - 对于关键词搜索(qmd search),qmd update通常足够(快速)。
- 如果依赖语义/混合搜索(vsearch/query),可能还需要qmd embed,但这可能较慢。
定时任务示例(cron):
bash
每小时增量更新(保持BM25新鲜):
0
export PATH=$HOME/.bun/bin:$PATH && qmd update
可选:夜间嵌入向量刷新(可能较慢):
0 5
* export PATH=$HOME/.bun/bin:$PATH && qmd embed
如果您的Clawdbot/代理环境支持内置调度器,可以在其中运行相同命令,而无需使用系统cron。
模型和缓存
- - 使用本地GGUF模型;首次运行自动下载。
- 默认缓存:~/.cache/qmd/models/(可通过XDGCACHEHOME覆盖)。
与Clawdbot记忆搜索的关系
- - qmd搜索的是您显式索引到集合中的本地文件(笔记/文档)。
- Clawdbot的memorysearch搜索的是代理记忆(之前交互中保存的事实/上下文)。
- 两者结合使用:memorysearch用于我们之前决定/学到了什么?,qmd用于我的磁盘上的笔记/文档中有什么?。