gitlab-search
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSearch Skill
搜索技能
Search operations for GitLab using raw endpoint calls.
glab api使用原始端点调用执行GitLab搜索操作。
glab apiQuick Reference
快速参考
| Operation | Command Pattern | Risk |
|---|---|---|
| Search projects | | - |
| Search issues | | - |
| Search MRs | | - |
| Search code | | - |
| Search commits | | - |
| Search users | | - |
| Search wiki | | - |
| Project search | | - |
| Group search | | - |
Risk Legend: - Safe | ⚠️ Caution | ⚠️⚠️ Warning | ⚠️⚠️⚠️ Danger
| 操作 | 命令模式 | 风险 |
|---|---|---|
| 搜索项目 | | - |
| 搜索issues | | - |
| 搜索MRs | | - |
| 搜索代码 | | - |
| 搜索提交记录 | | - |
| 搜索用户 | | - |
| 搜索wiki | | - |
| 项目内搜索 | | - |
| 群组内搜索 | | - |
风险说明:- 安全 | ⚠️ 注意 | ⚠️⚠️ 警告 | ⚠️⚠️⚠️ 危险
When to Use This Skill
何时使用此技能
ALWAYS use when:
- User wants to search or find something across GitLab
- User mentions "search", "find", "query", "look for"
- User asks "where is", "which project has", "find all"
- User wants to search code, issues, MRs, commits, or wikis
NEVER use when:
- User wants to list all items (use specific skill: gitlab-issue, gitlab-mr, etc.)
- User knows the exact project/issue/MR ID
- User wants to search local files (use grep/find locally)
请务必在以下场景使用:
- 用户想要在GitLab中搜索或查找内容
- 用户提到“搜索”、“查找”、“查询”、“寻找”
- 用户询问“在哪里”、“哪个项目包含”、“查找所有”
- 用户想要搜索代码、issues、MRs、提交记录或wiki
请勿在以下场景使用:
- 用户想要列出所有条目(使用特定技能:gitlab-issue、gitlab-mr等)
- 用户知道确切的项目/issue/MR ID
- 用户想要搜索本地文件(使用本地的grep/find命令)
API Prerequisites
API前置条件
Required Token Scopes: or
read_apiapiNote: Search results are limited to resources the authenticated user can access.
所需令牌权限范围: 或
read_apiapi注意:搜索结果仅限于已认证用户有权访问的资源。
Search Scopes
搜索范围
| Scope | Description | Available At |
|---|---|---|
| Search project names/descriptions | Global, Group |
| Search issue titles/descriptions | Global, Group, Project |
| Search MR titles/descriptions | Global, Group, Project |
| Search milestone titles | Global, Group, Project |
| Search snippet titles | Global |
| Search wiki content | Global, Group, Project |
| Search commit messages | Global, Group, Project |
| Search code/file content | Global, Group, Project |
| Search comments | Global, Group, Project |
| Search usernames/names | Global |
| 范围 | 描述 | 适用范围 |
|---|---|---|
| 搜索项目名称/描述 | 全局、群组 |
| 搜索issue标题/描述 | 全局、群组、项目 |
| 搜索MR标题/描述 | 全局、群组、项目 |
| 搜索里程碑标题 | 全局、群组、项目 |
| 搜索代码片段标题 | 全局 |
| 搜索wiki内容 | 全局、群组、项目 |
| 搜索提交信息 | 全局、群组、项目 |
| 搜索代码/文件内容 | 全局、群组、项目 |
| 搜索评论 | 全局、群组、项目 |
| 搜索用户名/姓名 | 全局 |
Available Commands
可用命令
Global Search
全局搜索
bash
undefinedbash
undefinedSearch projects by name
Search projects by name
glab api "search?scope=projects&search=api+gateway" --method GET
glab api "search?scope=projects&search=api+gateway" --method GET
Search issues globally
Search issues globally
glab api "search?scope=issues&search=authentication+bug" --method GET
glab api "search?scope=issues&search=authentication+bug" --method GET
Search merge requests
Search merge requests
glab api "search?scope=merge_requests&search=refactor" --method GET
glab api "search?scope=merge_requests&search=refactor" --method GET
Search code (blobs)
Search code (blobs)
glab api "search?scope=blobs&search=TODO+fixme" --method GET
glab api "search?scope=blobs&search=TODO+fixme" --method GET
Search commits
Search commits
glab api "search?scope=commits&search=fix+security" --method GET
glab api "search?scope=commits&search=fix+security" --method GET
Search wiki content
Search wiki content
glab api "search?scope=wiki_blobs&search=installation" --method GET
glab api "search?scope=wiki_blobs&search=installation" --method GET
Search users
Search users
glab api "search?scope=users&search=john" --method GET
glab api "search?scope=users&search=john" --method GET
Search milestones
Search milestones
glab api "search?scope=milestones&search=v2.0" --method GET
glab api "search?scope=milestones&search=v2.0" --method GET
Search comments/notes
Search comments/notes
glab api "search?scope=notes&search=approved" --method GET
undefinedglab api "search?scope=notes&search=approved" --method GET
undefinedProject-Scoped Search
项目范围搜索
bash
undefinedbash
undefinedSearch issues in specific project
Search issues in specific project
glab api "projects/123/search?scope=issues&search=bug" --method GET
glab api "projects/123/search?scope=issues&search=bug" --method GET
Search code in project
Search code in project
glab api "projects/123/search?scope=blobs&search=function+authenticate" --method GET
glab api "projects/123/search?scope=blobs&search=function+authenticate" --method GET
Search commits in project
Search commits in project
glab api "projects/123/search?scope=commits&search=fix" --method GET
glab api "projects/123/search?scope=commits&search=fix" --method GET
Search wiki in project
Search wiki in project
glab api "projects/123/search?scope=wiki_blobs&search=setup" --method GET
glab api "projects/123/search?scope=wiki_blobs&search=setup" --method GET
Search MRs in project
Search MRs in project
glab api "projects/123/search?scope=merge_requests&search=feature" --method GET
glab api "projects/123/search?scope=merge_requests&search=feature" --method GET
Search notes in project
Search notes in project
glab api "projects/123/search?scope=notes&search=LGTM" --method GET
glab api "projects/123/search?scope=notes&search=LGTM" --method GET
Search milestones in project
Search milestones in project
glab api "projects/123/search?scope=milestones&search=sprint" --method GET
glab api "projects/123/search?scope=milestones&search=sprint" --method GET
Using project path (URL-encoded)
Using project path (URL-encoded)
glab api "projects/$(echo 'mygroup/myproject' | jq -Rr @uri)/search?scope=blobs&search=TODO"
undefinedglab api "projects/$(echo 'mygroup/myproject' | jq -Rr @uri)/search?scope=blobs&search=TODO"
undefinedGroup-Scoped Search
群组范围搜索
bash
undefinedbash
undefinedSearch issues in group
Search issues in group
glab api "groups/456/search?scope=issues&search=urgent" --method GET
glab api "groups/456/search?scope=issues&search=urgent" --method GET
Search code across group
Search code across group
glab api "groups/456/search?scope=blobs&search=api+key" --method GET
glab api "groups/456/search?scope=blobs&search=api+key" --method GET
Search projects in group
Search projects in group
glab api "groups/456/search?scope=projects&search=backend" --method GET
glab api "groups/456/search?scope=projects&search=backend" --method GET
Search MRs in group
Search MRs in group
glab api "groups/456/search?scope=merge_requests&search=hotfix" --method GET
glab api "groups/456/search?scope=merge_requests&search=hotfix" --method GET
Using group path (URL-encoded)
Using group path (URL-encoded)
glab api "groups/$(echo 'mygroup' | jq -Rr @uri)/search?scope=issues&search=bug"
undefinedglab api "groups/$(echo 'mygroup' | jq -Rr @uri)/search?scope=issues&search=bug"
undefinedPagination
分页
bash
undefinedbash
undefinedGet more results per page
Get more results per page
glab api "search?scope=issues&search=bug&per_page=50" --method GET
glab api "search?scope=issues&search=bug&per_page=50" --method GET
Get specific page
Get specific page
glab api "search?scope=issues&search=bug&per_page=50&page=2" --method GET
glab api "search?scope=issues&search=bug&per_page=50&page=2" --method GET
Auto-paginate all results
Auto-paginate all results
glab api "search?scope=projects&search=api" --paginate
undefinedglab api "search?scope=projects&search=api" --paginate
undefinedAdvanced Search Syntax
高级搜索语法
bash
undefinedbash
undefinedExact phrase search (use quotes, URL-encoded)
Exact phrase search (use quotes, URL-encoded)
glab api "search?scope=blobs&search=%22exact+phrase%22" --method GET
glab api "search?scope=blobs&search=%22exact+phrase%22" --method GET
Filename filter in code search
Filename filter in code search
glab api "search?scope=blobs&search=authenticate+filename:auth.py" --method GET
glab api "search?scope=blobs&search=authenticate+filename:auth.py" --method GET
Extension filter
Extension filter
glab api "search?scope=blobs&search=class+extension:java" --method GET
glab api "search?scope=blobs&search=class+extension:java" --method GET
Path filter
Path filter
glab api "search?scope=blobs&search=config+path:src/main" --method GET
undefinedglab api "search?scope=blobs&search=config+path:src/main" --method GET
undefinedOutput Processing
输出处理
Extract Key Fields
提取关键字段
bash
undefinedbash
undefinedGet issue IDs and titles
Get issue IDs and titles
glab api "search?scope=issues&search=bug" |
jq -r '.[] | "(.project_id)#(.iid): (.title)"'
jq -r '.[] | "(.project_id)#(.iid): (.title)"'
glab api "search?scope=issues&search=bug" |
jq -r '.[] | "(.project_id)#(.iid): (.title)"'
jq -r '.[] | "(.project_id)#(.iid): (.title)"'
Get project names and URLs
Get project names and URLs
glab api "search?scope=projects&search=api" |
jq -r '.[] | "(.path_with_namespace): (.web_url)"'
jq -r '.[] | "(.path_with_namespace): (.web_url)"'
glab api "search?scope=projects&search=api" |
jq -r '.[] | "(.path_with_namespace): (.web_url)"'
jq -r '.[] | "(.path_with_namespace): (.web_url)"'
Get code matches with file paths
Get code matches with file paths
glab api "search?scope=blobs&search=TODO" |
jq -r '.[] | "(.project_id):(.path):(.startline) (.data)"'
jq -r '.[] | "(.project_id):(.path):(.startline) (.data)"'
glab api "search?scope=blobs&search=TODO" |
jq -r '.[] | "(.project_id):(.path):(.startline) (.data)"'
jq -r '.[] | "(.project_id):(.path):(.startline) (.data)"'
Get commit info
Get commit info
glab api "search?scope=commits&search=fix" |
jq -r '.[] | "(.short_id): (.title)"'
jq -r '.[] | "(.short_id): (.title)"'
undefinedglab api "search?scope=commits&search=fix" |
jq -r '.[] | "(.short_id): (.title)"'
jq -r '.[] | "(.short_id): (.title)"'
undefinedCount Results
统计结果
bash
undefinedbash
undefinedCount matching issues
Count matching issues
glab api "search?scope=issues&search=bug" --paginate | jq 'length'
glab api "search?scope=issues&search=bug" --paginate | jq 'length'
Count by project
Count by project
glab api "search?scope=issues&search=bug" --paginate |
jq 'group_by(.project_id) | map({project: .[0].project_id, count: length})'
jq 'group_by(.project_id) | map({project: .[0].project_id, count: length})'
undefinedglab api "search?scope=issues&search=bug" --paginate |
jq 'group_by(.project_id) | map({project: .[0].project_id, count: length})'
jq 'group_by(.project_id) | map({project: .[0].project_id, count: length})'
undefinedCommon Workflows
常见工作流
Workflow 1: Find All TODOs in Codebase
工作流1:查找代码库中所有TODO注释
bash
undefinedbash
undefinedSearch for TODO comments across all accessible projects
Search for TODO comments across all accessible projects
glab api "search?scope=blobs&search=TODO" --paginate |
jq -r '.[] | "(.project_id):(.path):(.startline)"'
jq -r '.[] | "(.project_id):(.path):(.startline)"'
undefinedglab api "search?scope=blobs&search=TODO" --paginate |
jq -r '.[] | "(.project_id):(.path):(.startline)"'
jq -r '.[] | "(.project_id):(.path):(.startline)"'
undefinedWorkflow 2: Find Issues Across Team Projects
工作流2:查找团队项目中的issues
bash
undefinedbash
undefinedGet group ID
Get group ID
group_id=$(glab api "groups/$(echo 'myteam' | jq -Rr @uri)" | jq -r '.id')
group_id=$(glab api "groups/$(echo 'myteam' | jq -Rr @uri)" | jq -r '.id')
Search for critical issues in group
Search for critical issues in group
glab api "groups/$group_id/search?scope=issues&search=critical" --paginate |
jq -r '.[] | "(.references.full): (.title)"'
jq -r '.[] | "(.references.full): (.title)"'
undefinedglab api "groups/$group_id/search?scope=issues&search=critical" --paginate |
jq -r '.[] | "(.references.full): (.title)"'
jq -r '.[] | "(.references.full): (.title)"'
undefinedWorkflow 3: Find Who Worked on Feature
工作流3:查找谁开发了某个功能
bash
undefinedbash
undefinedSearch commits mentioning feature
Search commits mentioning feature
glab api "projects/123/search?scope=commits&search=authentication" |
jq -r '.[] | "(.author_name): (.title)"'
jq -r '.[] | "(.author_name): (.title)"'
undefinedglab api "projects/123/search?scope=commits&search=authentication" |
jq -r '.[] | "(.author_name): (.title)"'
jq -r '.[] | "(.author_name): (.title)"'
undefinedWorkflow 4: Find Security-Related Code
工作流4:查找与安全相关的代码
bash
undefinedbash
undefinedSearch for potential security patterns
Search for potential security patterns
for term in "password" "secret" "api_key" "token"; do
echo "=== Searching for: $term ==="
glab api "projects/123/search?scope=blobs&search=$term" |
jq -r '.[] | "(.path):(.startline)"' done
jq -r '.[] | "(.path):(.startline)"' done
undefinedfor term in "password" "secret" "api_key" "token"; do
echo "=== Searching for: $term ==="
glab api "projects/123/search?scope=blobs&search=$term" |
jq -r '.[] | "(.path):(.startline)"' done
jq -r '.[] | "(.path):(.startline)"' done
undefinedWorkflow 5: Find Related MRs
工作流5:查找相关MRs
bash
undefinedbash
undefinedSearch MRs by feature name
Search MRs by feature name
glab api "search?scope=merge_requests&search=oauth+integration" |
jq -r '.[] | "!(.iid) [(.state)]: (.title)"'
jq -r '.[] | "!(.iid) [(.state)]: (.title)"'
undefinedglab api "search?scope=merge_requests&search=oauth+integration" |
jq -r '.[] | "!(.iid) [(.state)]: (.title)"'
jq -r '.[] | "!(.iid) [(.state)]: (.title)"'
undefinedSearch Tips
搜索技巧
Effective Search Terms
高效搜索关键词
| For | Search Examples |
|---|---|
| Bug fixes | |
| Features | |
| Refactoring | |
| Security | |
| Performance | |
| Documentation | |
| 用途 | 搜索示例 |
|---|---|
| 修复bug | |
| 功能开发 | |
| 代码重构 | |
| 安全相关 | |
| 性能优化 | |
| 文档相关 | |
URL Encoding Special Characters
特殊字符的URL编码
bash
undefinedbash
undefinedSpace -> +
Space -> +
glab api "search?scope=issues&search=fix+bug"
glab api "search?scope=issues&search=fix+bug"
Quotes (for exact match) -> %22
Quotes (for exact match) -> %22
glab api "search?scope=blobs&search=%22exact+phrase%22"
glab api "search?scope=blobs&search=%22exact+phrase%22"
Hash -> %23
Hash -> %23
glab api "search?scope=issues&search=issue%231234"
undefinedglab api "search?scope=issues&search=issue%231234"
undefinedTroubleshooting
故障排除
| Issue | Cause | Solution |
|---|---|---|
| Empty results | No matches or no access | Verify search term, check permissions |
| Partial results | Pagination needed | Use |
| 400 Bad Request | Invalid scope | Check scope is valid for endpoint |
| Slow search | Large result set | Add filters or narrow scope |
| No code results | Basic search disabled | Contact admin to enable advanced search |
| 问题 | 原因 | 解决方案 |
|---|---|---|
| 空结果 | 无匹配内容或无访问权限 | 验证搜索关键词,检查权限 |
| 结果不完整 | 需要分页 | 使用 |
| 400错误请求 | 无效的搜索范围 | 检查范围是否适用于当前端点 |
| 搜索缓慢 | 结果集过大 | 添加筛选条件或缩小搜索范围 |
| 无代码搜索结果 | 基础搜索已禁用 | 联系管理员启用高级搜索 |
Search Limitations
搜索限制
- Basic search searches titles/descriptions only
- Advanced search (Elasticsearch) required for code search
- Results limited to accessible resources
- Rate limits apply for large searches
- 基础搜索仅搜索标题/描述
- 代码搜索需要高级搜索(基于Elasticsearch)
- 结果仅限于有权访问的资源
- 大规模搜索会触发速率限制
Related Documentation
相关文档
- API Helpers
- Safeguards
- Quick Reference
- GitLab Search API
- API Helpers
- Safeguards
- Quick Reference
- GitLab Search API