gitlab-search

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Search Skill

搜索技能

Search operations for GitLab using
glab api
raw endpoint calls.
使用
glab api
原始端点调用执行GitLab搜索操作。

Quick Reference

快速参考

OperationCommand PatternRisk
Search projects
glab api "search?scope=projects&search=..."
-
Search issues
glab api "search?scope=issues&search=..."
-
Search MRs
glab api "search?scope=merge_requests&search=..."
-
Search code
glab api "search?scope=blobs&search=..."
-
Search commits
glab api "search?scope=commits&search=..."
-
Search users
glab api "search?scope=users&search=..."
-
Search wiki
glab api "search?scope=wiki_blobs&search=..."
-
Project search
glab api "projects/:id/search?scope=...&search=..."
-
Group search
glab api "groups/:id/search?scope=...&search=..."
-
Risk Legend: - Safe | ⚠️ Caution | ⚠️⚠️ Warning | ⚠️⚠️⚠️ Danger
操作命令模式风险
搜索项目
glab api "search?scope=projects&search=..."
-
搜索issues
glab api "search?scope=issues&search=..."
-
搜索MRs
glab api "search?scope=merge_requests&search=..."
-
搜索代码
glab api "search?scope=blobs&search=..."
-
搜索提交记录
glab api "search?scope=commits&search=..."
-
搜索用户
glab api "search?scope=users&search=..."
-
搜索wiki
glab api "search?scope=wiki_blobs&search=..."
-
项目内搜索
glab api "projects/:id/search?scope=...&search=..."
-
群组内搜索
glab api "groups/:id/search?scope=...&search=..."
-
风险说明:- 安全 | ⚠️ 注意 | ⚠️⚠️ 警告 | ⚠️⚠️⚠️ 危险

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:
read_api
or
api
Note: Search results are limited to resources the authenticated user can access.
所需令牌权限范围
read_api
api
注意:搜索结果仅限于已认证用户有权访问的资源。

Search Scopes

搜索范围

ScopeDescriptionAvailable At
projects
Search project names/descriptionsGlobal, Group
issues
Search issue titles/descriptionsGlobal, Group, Project
merge_requests
Search MR titles/descriptionsGlobal, Group, Project
milestones
Search milestone titlesGlobal, Group, Project
snippet_titles
Search snippet titlesGlobal
wiki_blobs
Search wiki contentGlobal, Group, Project
commits
Search commit messagesGlobal, Group, Project
blobs
Search code/file contentGlobal, Group, Project
notes
Search commentsGlobal, Group, Project
users
Search usernames/namesGlobal
范围描述适用范围
projects
搜索项目名称/描述全局、群组
issues
搜索issue标题/描述全局、群组、项目
merge_requests
搜索MR标题/描述全局、群组、项目
milestones
搜索里程碑标题全局、群组、项目
snippet_titles
搜索代码片段标题全局
wiki_blobs
搜索wiki内容全局、群组、项目
commits
搜索提交信息全局、群组、项目
blobs
搜索代码/文件内容全局、群组、项目
notes
搜索评论全局、群组、项目
users
搜索用户名/姓名全局

Available Commands

可用命令

Global Search

全局搜索

bash
undefined
bash
undefined

Search 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
undefined
glab api "search?scope=notes&search=approved" --method GET
undefined

Project-Scoped Search

项目范围搜索

bash
undefined
bash
undefined

Search 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"
undefined
glab api "projects/$(echo 'mygroup/myproject' | jq -Rr @uri)/search?scope=blobs&search=TODO"
undefined

Group-Scoped Search

群组范围搜索

bash
undefined
bash
undefined

Search 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"
undefined
glab api "groups/$(echo 'mygroup' | jq -Rr @uri)/search?scope=issues&search=bug"
undefined

Pagination

分页

bash
undefined
bash
undefined

Get 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
undefined
glab api "search?scope=projects&search=api" --paginate
undefined

Advanced Search Syntax

高级搜索语法

bash
undefined
bash
undefined

Exact 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
undefined
glab api "search?scope=blobs&search=config+path:src/main" --method GET
undefined

Output Processing

输出处理

Extract Key Fields

提取关键字段

bash
undefined
bash
undefined

Get issue IDs and titles

Get issue IDs and titles

glab api "search?scope=issues&search=bug" |
jq -r '.[] | "(.project_id)#(.iid): (.title)"'
glab api "search?scope=issues&search=bug" |
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)"'
glab api "search?scope=projects&search=api" |
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)"'
glab api "search?scope=blobs&search=TODO" |
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)"'
undefined
glab api "search?scope=commits&search=fix" |
jq -r '.[] | "(.short_id): (.title)"'
undefined

Count Results

统计结果

bash
undefined
bash
undefined

Count 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})'
undefined
glab api "search?scope=issues&search=bug" --paginate |
jq 'group_by(.project_id) | map({project: .[0].project_id, count: length})'
undefined

Common Workflows

常见工作流

Workflow 1: Find All TODOs in Codebase

工作流1:查找代码库中所有TODO注释

bash
undefined
bash
undefined

Search 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)"'
undefined
glab api "search?scope=blobs&search=TODO" --paginate |
jq -r '.[] | "(.project_id):(.path):(.startline)"'
undefined

Workflow 2: Find Issues Across Team Projects

工作流2:查找团队项目中的issues

bash
undefined
bash
undefined

Get 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)"'
undefined
glab api "groups/$group_id/search?scope=issues&search=critical" --paginate |
jq -r '.[] | "(.references.full): (.title)"'
undefined

Workflow 3: Find Who Worked on Feature

工作流3:查找谁开发了某个功能

bash
undefined
bash
undefined

Search commits mentioning feature

Search commits mentioning feature

glab api "projects/123/search?scope=commits&search=authentication" |
jq -r '.[] | "(.author_name): (.title)"'
undefined
glab api "projects/123/search?scope=commits&search=authentication" |
jq -r '.[] | "(.author_name): (.title)"'
undefined

Workflow 4: Find Security-Related Code

工作流4:查找与安全相关的代码

bash
undefined
bash
undefined

Search 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
undefined
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
undefined

Workflow 5: Find Related MRs

工作流5:查找相关MRs

bash
undefined
bash
undefined

Search MRs by feature name

Search MRs by feature name

glab api "search?scope=merge_requests&search=oauth+integration" |
jq -r '.[] | "!(.iid) [(.state)]: (.title)"'
undefined
glab api "search?scope=merge_requests&search=oauth+integration" |
jq -r '.[] | "!(.iid) [(.state)]: (.title)"'
undefined

Search Tips

搜索技巧

Effective Search Terms

高效搜索关键词

ForSearch Examples
Bug fixes
fix bug
,
resolve issue
,
patch
Features
add feature
,
implement
,
new
Refactoring
refactor
,
cleanup
,
improve
Security
security
,
vulnerability
,
CVE
Performance
performance
,
optimize
,
speed
Documentation
docs
,
readme
,
documentation
用途搜索示例
修复bug
fix bug
,
resolve issue
,
patch
功能开发
add feature
,
implement
,
new
代码重构
refactor
,
cleanup
,
improve
安全相关
security
,
vulnerability
,
CVE
性能优化
performance
,
optimize
,
speed
文档相关
docs
,
readme
,
documentation

URL Encoding Special Characters

特殊字符的URL编码

bash
undefined
bash
undefined

Space -> +

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"
undefined
glab api "search?scope=issues&search=issue%231234"
undefined

Troubleshooting

故障排除

IssueCauseSolution
Empty resultsNo matches or no accessVerify search term, check permissions
Partial resultsPagination neededUse
--paginate
flag
400 Bad RequestInvalid scopeCheck scope is valid for endpoint
Slow searchLarge result setAdd filters or narrow scope
No code resultsBasic search disabledContact admin to enable advanced search
问题原因解决方案
空结果无匹配内容或无访问权限验证搜索关键词,检查权限
结果不完整需要分页使用
--paginate
参数
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

相关文档