secondbrain-search
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSemantic Search
语义搜索
Search your secondbrain knowledge base using semantic similarity (meaning-based) and full-text search.
使用语义相似度(基于语义)和全文搜索功能检索你的secondbrain知识库。
Prerequisites
前提条件
-
qmd installed: Check with
which qmd- Install: or
bun install -g qmdnpm install -g qmd - First run downloads ~1.5GB models
- Install:
-
Search initialized: Check fordirectory
.claude/search/- If not initialized, suggest running
/secondbrain-search-init
- If not initialized, suggest running
-
已安装qmd:使用命令检查
which qmd- 安装方式:或
bun install -g qmdnpm install -g qmd - 首次运行会下载约1.5GB的模型
- 安装方式:
-
已初始化搜索:检查是否存在目录
.claude/search/- 若未初始化,建议运行
/secondbrain-search-init
- 若未初始化,建议运行
Usage
使用方法
/secondbrain-search "your natural language query"
/secondbrain-search --entity=adrs "database migration"
/secondbrain-search --recent=30d "authentication"
/secondbrain-search --status=active --tag=kubernetes "deployment"/secondbrain-search "你的自然语言查询语句"
/secondbrain-search --entity=adrs "数据库迁移"
/secondbrain-search --recent=30d "身份验证"
/secondbrain-search --status=active --tag=kubernetes "部署"Workflow
工作流程
Step 1: Validate Environment
步骤1:验证环境
bash
undefinedbash
undefinedCheck qmd is installed
检查qmd是否已安装
which qmd
which qmd
Check search is initialized
检查搜索是否已初始化
ls .claude/search/
If qmd not installed:qmd is not installed. Install it with:
bun install -g qmd
or
npm install -g qmd
Then initialize search with: /secondbrain-search-init
If search not initialized:Search not initialized for this project.
Run: /secondbrain-search-init
undefinedls .claude/search/
若未安装qmd:qmd未安装。可通过以下命令安装:
bun install -g qmd
或
npm install -g qmd
然后运行以下命令初始化搜索:/secondbrain-search-init
若未初始化搜索:当前项目未初始化搜索功能。
请运行:/secondbrain-search-init
undefinedStep 2: Parse Query and Filters
步骤2:解析查询语句与筛选条件
Extract from user input:
| Filter | Syntax | Example |
|---|---|---|
| Entity | | |
| Recent | | |
| Date from | | |
| Date to | | |
| Status | | |
| Tag | | |
| Limit | | |
| Format | | |
从用户输入中提取以下内容:
| 筛选条件 | 语法 | 示例 |
|---|---|---|
| 实体类型 | | |
| 时间范围(最近) | | |
| 起始日期 | | |
| 结束日期 | | |
| 状态 | | |
| 标签 | | |
| 结果数量限制 | | |
| 输出格式 | | |
Step 3: Execute Search
步骤3:执行搜索
Run qmd search command:
bash
cd <project_root>
qmd query "<user_query>" --json --limit=<limit>Parse JSON output:
json
{
"results": [
{
"id": "docs/adrs/ADR-0012-kubernetes-deployment.md",
"score": 0.92,
"title": "Kubernetes Deployment Strategy",
"excerpt": "We decided to use Blue-Green deployment for stateless services...",
"metadata": {
"frontmatter": {
"status": "implemented",
"created": "2025-12-15"
}
}
}
]
}运行qmd搜索命令:
bash
cd <项目根目录>
qmd query "<用户查询语句>" --json --limit=<数量限制>解析JSON输出:
json
{
"results": [
{
"id": "docs/adrs/ADR-0012-kubernetes-deployment.md",
"score": 0.92,
"title": "Kubernetes Deployment Strategy",
"excerpt": "We decided to use Blue-Green deployment for stateless services...",
"metadata": {
"frontmatter": {
"status": "implemented",
"created": "2025-12-15"
}
}
}
]
}Step 4: Enrich with Metadata
步骤4:补充元数据
Load YAML records to add entity-specific metadata:
For each result:
- Determine entity type from file path (e.g., → ADRs)
docs/adrs/ - Load corresponding records from
.claude/data/<entity>/records.yaml - Match by file path and enrich with status, tags, dates, etc.
加载YAML记录以添加实体特定的元数据:
针对每个搜索结果:
- 根据文件路径确定实体类型(例如:→ ADRs)
docs/adrs/ - 从加载对应的记录
.claude/data/<实体类型>/records.yaml - 通过文件路径匹配,补充状态、标签、日期等信息
Step 5: Apply Post-Filters
步骤5:应用后置筛选
Filter results based on user criteria:
python
undefined根据用户的条件筛选结果:
python
undefinedPseudocode
伪代码
for result in results:
if entity_filter and result.entity not in entity_filter:
skip
if status_filter and result.status != status_filter:
skip
if tag_filter and tag_filter not in result.tags:
skip
if date_filter and not in_date_range(result.date, from_date, to_date):
skip
undefinedfor result in results:
if entity_filter and result.entity not in entity_filter:
skip
if status_filter and result.status != status_filter:
skip
if tag_filter and tag_filter not in result.tags:
skip
if date_filter and not in_date_range(result.date, from_date, to_date):
skip
undefinedStep 6: Format Output
步骤6:格式化输出
Brief Format (default for >3 results)
简洁格式(结果数量>3时默认使用)
undefinedundefinedSearch Results
搜索结果
Query: "kubernetes deployment"
Results: 4 matches
-
[ADR-0012] Kubernetes Deployment Strategy (0.92) Status: implemented | Updated: 2025-12-15
-
[Note] Kubernetes Scaling Best Practices (0.87) Tags: kubernetes, scaling | Created: 2025-11-20
-
[Discussion] Platform Team - Deployment Pipeline (0.79) Date: 2025-10-05 | Participants: Alice, Bob
-
[Task] Implement Canary Deployments (0.71) Status: in_progress | Priority: high
undefined查询语句: "kubernetes deployment"
匹配结果: 4条
-
[ADR-0012] Kubernetes Deployment Strategy (0.92) 状态: implemented | 更新日期: 2025-12-15
-
[Note] Kubernetes Scaling Best Practices (0.87) 标签: kubernetes, scaling | 创建日期: 2025-11-20
-
[Discussion] Platform Team - Deployment Pipeline (0.79) 日期: 2025-10-05 | 参与人: Alice, Bob
-
[Task] Implement Canary Deployments (0.71) 状态: in_progress | 优先级: high
undefinedDetailed Format (default for ≤3 results)
详细格式(结果数量≤3时默认使用)
undefinedundefinedSearch Results
搜索结果
Query: "kubernetes deployment"
Results: 2 matches
查询语句: "kubernetes deployment"
匹配结果: 2条
1. [ADR-0012] Kubernetes Deployment Strategy
1. [ADR-0012] Kubernetes Deployment Strategy
Score: 0.92 | Status: implemented | Category: infrastructure
File: ADR-0012-kubernetes-deployment.md
Excerpt:
We decided to use Blue-Green deployment for stateless services and Rolling updates for stateful workloads. This approach provides zero-downtime deployments while minimizing resource overhead...
Metadata:
- Created: 2025-12-15
- Author: sergey
- Category: infrastructure
匹配得分: 0.92 | 状态: implemented | 分类: infrastructure
文件: ADR-0012-kubernetes-deployment.md
内容摘要:
We decided to use Blue-Green deployment for stateless services and Rolling updates for stateful workloads. This approach provides zero-downtime deployments while minimizing resource overhead...
元数据:
- 创建日期: 2025-12-15
- 作者: sergey
- 分类: infrastructure
2. [Note] Kubernetes Scaling Best Practices
2. [Note] Kubernetes Scaling Best Practices
Score: 0.87 | Tags: kubernetes, scaling
File: 2025-11-20-kubernetes-scaling.md
Excerpt:
Key considerations for scaling Kubernetes deployments:
- Horizontal Pod Autoscaler configuration
- Resource requests and limits
- Pod disruption budgets...
Metadata:
- Created: 2025-11-20
- Status: active
undefined匹配得分: 0.87 | 标签: kubernetes, scaling
文件: 2025-11-20-kubernetes-scaling.md
内容摘要:
Key considerations for scaling Kubernetes deployments:
- Horizontal Pod Autoscaler configuration
- Resource requests and limits
- Pod disruption budgets...
元数据:
- 创建日期: 2025-11-20
- 状态: active
undefinedJSON Format
JSON格式
json
{
"query": "kubernetes deployment",
"total": 4,
"results": [
{
"entity": "adrs",
"id": "ADR-0012",
"title": "Kubernetes Deployment Strategy",
"file": "docs/adrs/ADR-0012-kubernetes-deployment.md",
"score": 0.92,
"excerpt": "We decided to use Blue-Green deployment...",
"metadata": {
"status": "implemented",
"category": "infrastructure",
"created": "2025-12-15",
"author": "sergey"
}
}
]
}json
{
"query": "kubernetes deployment",
"total": 4,
"results": [
{
"entity": "adrs",
"id": "ADR-0012",
"title": "Kubernetes Deployment Strategy",
"file": "docs/adrs/ADR-0012-kubernetes-deployment.md",
"score": 0.92,
"excerpt": "We decided to use Blue-Green deployment...",
"metadata": {
"status": "implemented",
"category": "infrastructure",
"created": "2025-12-15",
"author": "sergey"
}
}
]
}Search Tips
搜索技巧
Display helpful tips when no results found:
undefined当未找到结果时,显示实用提示:
undefinedNo Results Found
未找到匹配结果
Query: "foobar nonexistent"
查询语句: "foobar nonexistent"
Tips
提示
- Try broader terms — Use general concepts instead of specific jargon
- Check spelling — Semantic search handles typos but exact terms may miss
- Remove filters — Try without --entity or --status filters first
- Use related concepts — "authentication" instead of "OAuth2"
- 尝试更宽泛的术语 — 使用通用概念而非特定行话
- 检查拼写 — 语义搜索可处理拼写错误,但精确术语可能仍会遗漏
- 移除筛选条件 — 先尝试不使用--entity或--status筛选条件
- 使用相关概念 — 用"身份验证"代替"OAuth2"
Alternative Actions
替代操作
- — See all recent content
/secondbrain-freshness - Run without filters:
/secondbrain-search "foobar"
undefined- — 查看所有近期内容
/secondbrain-freshness - 不使用筛选条件运行:
/secondbrain-search "foobar"
undefinedRefine Search
优化搜索
After showing results, offer refinement options:
undefined展示搜索结果后,提供优化选项:
undefinedRefine Search
优化搜索
- — Filter to ADRs only
--entity=adrs - — Limit to last 30 days
--recent=30d - — Exclude archived items
--status=active - — Boolean operators
"kubernetes AND deployment"
undefined- — 仅筛选ADRs内容
--entity=adrs - — 限制为最近30天的内容
--recent=30d - — 排除已归档项目
--status=active - — 使用布尔运算符
"kubernetes AND deployment"
undefinedRelated Skills
相关Skill
- secondbrain-search-init — Initialize search for this project
- secondbrain-freshness — View items by freshness/staleness
- secondbrain-search-init — 初始化当前项目的搜索功能
- secondbrain-freshness — 按新鲜度/过时程度查看内容