qmd
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseQMD - Quick Markdown Search
QMD - 快速Markdown搜索工具
Local search engine for markdown content.
用于Markdown内容的本地搜索引擎。
Status
状态
!
qmd status 2>/dev/null || echo "Not installed: npm install -g @tobilu/qmd"!
qmd status 2>/dev/null || echo "Not installed: npm install -g @tobilu/qmd"MCP: query
queryMCP: query
queryjson
{
"searches": [
{ "type": "lex", "query": "CAP theorem consistency" },
{ "type": "vec", "query": "tradeoff between consistency and availability" }
],
"collections": ["docs"],
"limit": 10
}json
{
"searches": [
{ "type": "lex", "query": "CAP theorem consistency" },
{ "type": "vec", "query": "tradeoff between consistency and availability" }
],
"collections": ["docs"],
"limit": 10
}Query Types
查询类型
| Type | Method | Input |
|---|---|---|
| BM25 | Keywords — exact terms, names, code |
| Vector | Question — natural language |
| Vector | Answer — hypothetical result (50-100 words) |
| 类型 | 方法 | 输入 |
|---|---|---|
| BM25 | 关键词 — 精确术语、名称、代码 |
| 向量 | 问题 — 自然语言 |
| 向量 | 答案 — 假设性结果(50-100字) |
Writing Good Queries
如何写出高质量的查询语句
lex (keyword)
- 2-5 terms, no filler words
- Exact phrase: (quoted)
"connection pool" - Exclude terms: (minus prefix)
performance -sports - Code identifiers work:
handleError async
vec (semantic)
- Full natural language question
- Be specific:
"how does the rate limiter handle burst traffic" - Include context:
"in the payment service, how are refunds processed"
hyde (hypothetical document)
- Write 50-100 words of what the answer looks like
- Use the vocabulary you expect in the result
expand (auto-expand)
- Use a single-line query (implicit) or on its own line
expand: question - Lets the local LLM generate lex/vec/hyde variations
- Do not mix with other typed lines — it's either a standalone expand query or a full query document
expand:
lex (关键词)
- 2-5个术语,无填充词
- 精确短语:(加引号)
"connection pool" - 排除术语:(加前缀减号)
performance -sports - 支持代码标识符:
handleError async
vec (语义)
- 完整的自然语言问题
- 尽量具体:
"how does the rate limiter handle burst traffic" - 包含上下文:
"in the payment service, how are refunds processed"
hyde (假设文档)
- 撰写50-100字描述你期望的答案内容
- 使用你认为结果中会出现的词汇
expand (自动扩展)
- 使用单行查询(隐式)或单独一行写
expand: 问题 - 让本地LLM生成lex/vec/hyde的变体查询
- 不要将和其他类型的行混合使用 — 要么是独立的expand查询,要么是完整的查询文档
expand:
Intent (Disambiguation)
意图(消歧)
When a query term is ambiguous, add to steer results:
intentjson
{
"searches": [
{ "type": "lex", "query": "performance" }
],
"intent": "web page load times and Core Web Vitals"
}Intent affects expansion, reranking, chunk selection, and snippet extraction. It does not search on its own — it's a steering signal that disambiguates queries like "performance" (web-perf vs team health vs fitness).
当查询术语存在歧义时,添加来引导结果:
intentjson
{
"searches": [
{ "type": "lex", "query": "performance" }
],
"intent": "web page load times and Core Web Vitals"
}意图会影响查询扩展、重排序、片段选择和摘要提取。它本身不会执行搜索 — 它是一个引导信号,用于消除类似“performance”这类查询的歧义(是网页性能、团队健康还是健身相关)。
Combining Types
查询类型组合
| Goal | Approach |
|---|---|
| Know exact terms | |
| Don't know vocabulary | Use a single-line query (implicit |
| Best recall | |
| Complex topic | |
| Ambiguous query | Add |
First query gets 2x weight in fusion — put your best guess first.
| 目标 | 方案 |
|---|---|
| 知道精确术语 | 仅用 |
| 不清楚相关词汇 | 使用单行查询(隐式 |
| 最高召回率 | |
| 复杂主题 | |
| 歧义查询 | 在以上任意组合中添加 |
第一个查询在融合时权重翻倍 — 把你认为最可能的查询放在最前面。
Lex Query Syntax
Lex查询语法
| Syntax | Meaning | Example |
|---|---|---|
| Prefix match | |
| Exact phrase | |
| Exclude | |
Note: only works in lex queries, not vec/hyde.
-term| 语法 | 含义 | 示例 |
|---|---|---|
| 前缀匹配 | |
| 精确短语匹配 | |
| 排除该术语 | |
注意:仅在lex查询中生效,vec/hyde查询不支持。
-termCollection Filtering
集合过滤
json
{ "collections": ["docs"] } // Single
{ "collections": ["docs", "notes"] } // Multiple (OR)Omit to search all collections.
json
{ "collections": ["docs"] } // 单个集合
{ "collections": ["docs", "notes"] } // 多个集合(OR逻辑)省略该字段则搜索所有集合。
Other MCP Tools
其他MCP工具
| Tool | Use |
|---|---|
| Retrieve doc by path or |
| Retrieve multiple by glob/list |
| Collections and health |
| 工具 | 用途 |
|---|---|
| 通过路径或 |
| 通过通配符/列表获取多个文档 |
| 查看集合和服务健康状态 |
CLI
CLI
bash
qmd query "question" # Auto-expand + rerank
qmd query $'lex: X\nvec: Y' # Structured
qmd query $'expand: question' # Explicit expand
qmd query --json --explain "q" # Show score traces (RRF + rerank blend)
qmd search "keywords" # BM25 only (no LLM)
qmd get "#abc123" # By docid
qmd multi-get "journals/2026-*.md" -l 40 # Batch pull snippets by glob
qmd multi-get notes/foo.md,notes/bar.md # Comma-separated list, preserves orderbash
qmd query "question" # 自动扩展 + 重排序
qmd query $'lex: X\nvec: Y' # 结构化查询
qmd query $'expand: question' # 显式扩展
qmd query --json --explain "q" # 显示得分追踪(RRF + 重排序混合)
qmd search "keywords" # 仅BM25搜索(无LLM参与)
qmd get "#abc123" # 通过docid获取
qmd multi-get "journals/2026-*.md" -l 40 # 按通配符批量拉取片段
qmd multi-get notes/foo.md,notes/bar.md # 逗号分隔列表,保留顺序HTTP API
HTTP API
bash
curl -X POST http://localhost:8181/query \
-H "Content-Type: application/json" \
-d '{"searches": [{"type": "lex", "query": "test"}]}'bash
curl -X POST http://localhost:8181/query \
-H "Content-Type: application/json" \
-d '{"searches": [{"type": "lex", "query": "test"}]}'Setup
安装配置
bash
npm install -g @tobilu/qmd
qmd collection add ~/notes --name notes
qmd embedbash
npm install -g @tobilu/qmd
qmd collection add ~/notes --name notes
qmd embed