InfoGrab DocsInfoGrab Docs

Search API

요약

이 API를 사용하여 GitLab 전체에서 검색할 수 있습니다. 일부 스코프는 기본 검색에서 사용할 수 있습니다. 기본 검색을 대신 사용하려면 검색 유형 지정을 참고합니다. Search API는 오프셋 기반 페이지네이션을 지원합니다.

이 API를 사용하여 GitLab 전체에서 검색할 수 있습니다. 이 API에 대한 모든 호출에는 인증이 필요합니다.

일부 스코프는 기본 검색에서 사용할 수 있습니다. 고급 검색 또는 정확한 코드 검색이 활성화된 경우, 전역 검색, 그룹 검색, 프로젝트 검색 작업에서 추가 스코프를 사용할 수 있습니다.

기본 검색을 대신 사용하려면 검색 유형 지정을 참고합니다.

Search API는 오프셋 기반 페이지네이션을 지원합니다.

고급 검색에서는 최대 10,000건의 결과(page 곱하기 per_page)를 가져올 수 있습니다. 이 한도를 넘는 요청은 next 링크가 없는 빈 페이지를 반환하므로, 빈 응답을 받을 때까지 페이지를 넘기는 클라이언트는 이 한도에서 멈춥니다. 기본 검색과 정확한 코드 검색은 영향을 받지 않습니다. GitLab이 해당 설정을 읽지 않으므로, Elasticsearch 클러스터에서 index.max_result_window 값을 올려도 한도는 늘어나지 않습니다.

인스턴스 검색#

GitLab 인스턴스 전체에서 용어를 검색합니다. 응답은 요청된 스코프에 따라 달라집니다.

GET /search
Attribute Type Required Description
scope string Yes 검색할 스코프. 값에는 projects, groups, issues, work_items, merge_requests, milestones, snippet_titles, users가 포함됩니다. 추가 스코프로는 wiki_blobs, commits, blobs, notes가 있습니다.
search string Yes 검색어.
search_type string No 사용할 검색 유형. 값에는 basic, advanced, zoekt가 포함됩니다.
confidential boolean No 기밀성으로 필터링합니다. issues 및 work_items 스코프를 지원하며, 다른 스코프는 무시됩니다.
exclude_forks boolean No 검색에서 포크된 프로젝트를 제외합니다. 정확한 코드 검색에서 사용할 수 있습니다. 설정하지 않으면 포크가 제외됩니다. GitLab 18.7에서 도입되었습니다.
regex boolean No 코드 검색 시 정규 표현식을 사용합니다. 정확한 코드 검색에서 사용할 수 있습니다. 설정하지 않으면 정규 표현식이 사용됩니다. GitLab 18.9에서 도입되었습니다.
fields array of strings No 검색할 필드의 배열로, 허용되는 값은 title만 해당합니다. issues 및 merge_requests 스코프만 지원됩니다. Premium 및 Ultimate 전용.
include_archived boolean No 검색에 아카이브된 프로젝트를 포함합니다. 기본값은 false입니다. GitLab 18.7에서 도입되었습니다.
num_context_lines integer No 결과에서 각 일치 항목 주변에 포함할 컨텍스트 라인 수. 고급 검색 및 정확한 코드 검색에서만 사용할 수 있습니다. GitLab 18.11에서 도입되었습니다.
state string No 상태로 필터링합니다. issues, work_items, merge_requests 스코프를 지원하며, 다른 스코프는 무시됩니다.
type array of strings No 유형별로 작업 항목을 필터링합니다. work_items 스코프에만 적용됩니다. 사용 가능한 유형: issue, task, epic, incident, test_case, requirement, objective, key_result, ticket.
order_by string No 허용되는 값은 created_at만 해당합니다. 설정하지 않으면 기본 검색에서는 created_at 내림차순으로, 고급 검색에서는 가장 관련성 높은 문서 순으로 결과가 정렬됩니다.
sort string No 허용되는 값은 asc 또는 desc만 해당합니다. 설정하지 않으면 기본 검색에서는 created_at 내림차순으로, 고급 검색에서는 가장 관련성 높은 문서 순으로 결과가 정렬됩니다.

스코프: projects#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=projects&search=flight"

응답 예시:

[
  {
    "id": 6,
    "description": "Nobis sed ipsam vero quod cupiditate veritatis hic.",
    "name": "Flight",
    "name_with_namespace": "Twitter / Flight",
    "path": "flight",
    "path_with_namespace": "twitter/flight",
    "created_at": "2017-09-05T07:58:01.621Z",
    "default_branch": "main",
    "tag_list":[], //deprecated, use `topics` instead
    "topics":[],
    "ssh_url_to_repo": "ssh://jarka@localhost:2222/twitter/flight.git",
    "http_url_to_repo": "http://localhost:3000/twitter/flight.git",
    "web_url": "http://localhost:3000/twitter/flight",
    "readme_url": "http://localhost:3000/twitter/flight/-/blob/main/README.md",
    "avatar_url": null,
    "star_count": 0,
    "forks_count": 0,
    "last_activity_at": "2018-01-31T09:56:30.902Z"
  }
]

스코프: groups#

히스토리
  • GitLab 19.4에서 elasticsearch_group_search라는 기능 플래그와 함께 도입되었습니다. 기본적으로 비활성화됩니다.
Feature flag

이 스코프의 사용 가능 여부는 기능 플래그로 제어됩니다. 자세한 내용은 히스토리를 참고합니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=groups&search=flight"

응답 예시:

[
  {
    "id": 3,
    "web_url": "http://localhost:3000/groups/flightjs",
    "name": "Flightjs"
  }
]

스코프: issues#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=issues&search=file"

응답 예시:

[
  {
    "id": 83,
    "iid": 1,
    "project_id": 12,
    "title": "Add file",
    "description": "Add first file",
    "state": "opened",
    "created_at": "2018-01-24T06:02:15.514Z",
    "updated_at": "2018-02-06T12:36:23.263Z",
    "closed_at": null,
    "labels":[],
    "milestone": null,
    "assignees": [{
      "id": 20,
      "name": "Ceola Deckow",
      "username": "sammy.collier",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/c23d85a4f50e0ea76ab739156c639231?s=80&d=identicon",
      "web_url": "http://localhost:3000/sammy.collier"
    }],
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "assignee": {
      "id": 20,
      "name": "Ceola Deckow",
      "username": "sammy.collier",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/c23d85a4f50e0ea76ab739156c639231?s=80&d=identicon",
      "web_url": "http://localhost:3000/sammy.collier"
    },
    "user_notes_count": 0,
    "upvotes": 0,
    "downvotes": 0,
    "due_date": null,
    "confidential": false,
    "discussion_locked": null,
    "web_url": "http://localhost:3000/h5bp/7bp/subgroup-prj/issues/1",
    "time_stats": {
      "time_estimate": 0,
      "total_time_spent": 0,
      "human_time_estimate": null,
      "human_total_time_spent": null
    }
  }
]
Note

assignee 칼럼은 더 이상 사용되지 않습니다. GitLab EE API를 따르기 위해 크기가 1인 배열 assignees로 표시됩니다.

스코프: work_items#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=work_items&search=migrate"

응답 예시:

[
  {
    "id": 142,
    "iid": 9,
    "project_id": 12,
    "title": "Migrate to new database",
    "description": "Database migration task",
    "state": "opened",
    "created_at": "2018-03-15T08:12:31.489Z",
    "updated_at": "2018-03-20T14:22:18.371Z",
    "closed_at": null,
    "labels": ["backend"],
    "milestone": null,
    "assignees": [{
      "id": 25,
      "name": "John Doe",
      "username": "john.doe",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/a1b2c3d4e5f6g7h8i9j0?s=80&d=identicon",
      "web_url": "http://localhost:3000/john.doe"
    }],
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "type": "TASK",
    "user_notes_count": 2,
    "upvotes": 1,
    "downvotes": 0,
    "due_date": "2018-04-01",
    "confidential": false,
    "discussion_locked": null,
    "web_url": "http://localhost:3000/my-group/my-project/-/work_items/9",
    "time_stats": {
      "time_estimate": 0,
      "total_time_spent": 0,
      "human_time_estimate": null,
      "human_total_time_spent": null
    }
  }
]

type 파라미터를 사용하여 작업 항목을 유형별로 필터링할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=work_items&search=backend&type[]=task&type[]=issue"

스코프: merge_requests#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=merge_requests&search=file"

응답 예시:

[
  {
    "id": 56,
    "iid": 8,
    "project_id": 6,
    "title": "Add first file",
    "description": "This is a test MR to add file",
    "state": "opened",
    "created_at": "2018-01-22T14:21:50.830Z",
    "updated_at": "2018-02-06T12:40:33.295Z",
    "target_branch": "main",
    "source_branch": "jaja-test",
    "upvotes": 0,
    "downvotes": 0,
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "assignee": {
      "id": 5,
      "name": "Jacquelyn Kutch",
      "username": "abigail",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/3138c66095ee4bd11a508c2f7f7772da?s=80&d=identicon",
      "web_url": "http://localhost:3000/abigail"
    },
    "source_project_id": 6,
    "target_project_id": 6,
    "labels": [
      "ruby",
      "tests"
    ],
    "draft": false,
    "work_in_progress": false,
    "milestone": {
      "id": 13,
      "iid": 3,
      "project_id": 6,
      "title": "v2.0",
      "description": "Qui aut qui eos dolor beatae itaque tempore molestiae.",
      "state": "active",
      "created_at": "2017-09-05T07:58:29.099Z",
      "updated_at": "2017-09-05T07:58:29.099Z",
      "due_date": null,
      "start_date": null
    },
    "merge_when_pipeline_succeeds": false,
    "merge_status": "can_be_merged",
    "sha": "78765a2d5e0a43585945c58e61ba2f822e4d090b",
    "merge_commit_sha": null,
    "squash_commit_sha": null,
    "user_notes_count": 0,
    "discussion_locked": null,
    "should_remove_source_branch": null,
    "force_remove_source_branch": true,
    "web_url": "http://localhost:3000/twitter/flight/merge_requests/8",
    "time_stats": {
      "time_estimate": 0,
      "total_time_spent": 0,
      "human_time_estimate": null,
      "human_total_time_spent": null
    }
  }
]

스코프: milestones#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=milestones&search=release"

응답 예시:

[
  {
    "id": 44,
    "iid": 1,
    "project_id": 12,
    "title": "next release",
    "description": "Next release milestone",
    "state": "active",
    "created_at": "2018-02-06T12:43:39.271Z",
    "updated_at": "2018-02-06T12:44:01.298Z",
    "due_date": "2018-04-18",
    "start_date": "2018-02-04"
  }
]

스코프: snippet_titles#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=snippet_titles&search=sample"

응답 예시:

[
  {
    "id": 50,
    "title": "Sample file",
    "file_name": "file.rb",
    "description": "Simple ruby file",
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "updated_at": "2018-02-06T12:49:29.104Z",
    "created_at": "2017-11-28T08:20:18.071Z",
    "project_id": 9,
    "web_url": "http://localhost:3000/root/jira-test/snippets/50"
  }
]

스코프: users#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=users&search=doe"

응답 예시:

[
  {
    "id": 1,
    "name": "John Doe1",
    "username": "user1",
    "state": "active",
    "avatar_url": "http://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80&d=identicon",
    "web_url": "http://localhost/user1"
  }
]

스코프: wiki_blobs#

이 스코프를 사용하여 위키를 검색합니다.

이 스코프는 고급 검색이 활성화된 경우에만 사용할 수 있습니다.

이 스코프에서는 다음 필터를 사용할 수 있습니다.

  • filename
  • path
  • extension

필터를 사용하려면 쿼리에 해당 필터를 포함합니다(예: a query filename:some_name*).

glob 매칭에는 와일드카드(*)를 사용할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=wiki_blobs&search=bye"

응답 예시:


[
  {
    "basename": "home",
    "data": "hello\n\nand bye\n\nend",
    "path": "home.md",
    "filename": "home.md",
    "id": null,
    "ref": "main",
    "startline": 5,
    "project_id": 6,
    "group_id": null
  }
]
Note

filename은 path로 대체되어 더 이상 사용되지 않습니다. 둘 다 리포지터리 내 파일의 전체 경로를 반환하지만, 앞으로 filename은 전체 경로가 아닌 파일 이름만 나타낼 예정입니다. 자세한 내용은 이슈 34521을 참고합니다.

스코프: commits#

이 스코프는 고급 검색이 활성화된 경우에만 사용할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=commits&search=bye"

응답 예시:


[
  {
  "id": "4109c2d872d5fdb1ed057400d103766aaea97f98",
  "short_id": "4109c2d8",
  "title": "goodbye $.browser",
  "created_at": "2013-02-18T22:02:54.000Z",
  "parent_ids": [
    "59d05353ab575bcc2aa958fe1782e93297de64c9"
  ],
  "message": "goodbye $.browser\n",
  "author_name": "angus croll",
  "author_email": "anguscroll@gmail.com",
  "authored_date": "2013-02-18T22:02:54.000Z",
  "committer_name": "angus croll",
  "committer_email": "anguscroll@gmail.com",
  "committed_date": "2013-02-18T22:02:54.000Z",
  "project_id": 6
  }
]

스코프: blobs#

이 스코프를 사용하여 코드를 검색합니다.

이 스코프는 고급 검색 또는 정확한 코드 검색이 활성화된 경우에만 사용할 수 있습니다.

이 스코프에서는 다음 필터를 사용할 수 있습니다.

  • filename
  • path
  • extension

필터를 사용하려면 쿼리에 해당 필터를 포함합니다(예: a query filename:some_name*).

glob 매칭에는 와일드카드(*)를 사용할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=blobs&search=installation"

응답 예시:


[
  {
    "basename": "README",
    "data": "```\n\n## Installation\n\nQuick start using the [pre-built",
    "path": "README.md",
    "filename": "README.md",
    "id": null,
    "ref": "main",
    "startline": 46,
    "project_id": 6
  }
]
Note

filename은 path로 대체되어 더 이상 사용되지 않습니다. 둘 다 리포지터리 내 파일의 전체 경로를 반환하지만, 앞으로 filename은 전체 경로가 아닌 파일 이름만 나타낼 예정입니다. 자세한 내용은 이슈 34521을 참고합니다. Elasticsearch 구문은 정확한 코드 검색에서 제대로 동작하지 않을 수 있습니다. 정확한 코드 검색에서는 Elasticsearch 와일드카드 쿼리를 정규 표현식으로 대체합니다. 자세한 내용은 이슈 521686을 참고합니다.

스코프: notes#

이 스코프는 고급 검색이 활성화된 경우에만 사용할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=notes&search=maxime"

응답 예시:

[
  {
    "id": 191,
    "body": "Harum maxime consequuntur et et deleniti assumenda facilis.",
    "attachment": null,
    "author": {
      "id": 23,
      "name": "User 1",
      "username": "user1",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/111d68d06e2d317b5a59c2c6c5bad808?s=80&d=identicon",
      "web_url": "http://localhost:3000/user1"
    },
    "created_at": "2017-09-05T08:01:32.068Z",
    "updated_at": "2017-09-05T08:01:32.068Z",
    "system": false,
    "noteable_id": 22,
    "noteable_type": "Issue",
    "project_id": 6,
    "noteable_iid": 2
  }
]

그룹 검색#

지정된 그룹에서 용어를 검색합니다.

사용자가 그룹의 멤버가 아니고 해당 그룹이 비공개인 경우, 해당 그룹에 대한 GET 요청은 404 Not Found 상태 코드를 반환합니다.

GET /groups/:id/search
Attribute Type Required Description
id integer or string Yes 그룹의 ID 또는 URL 인코딩된 경로.
scope string Yes 검색할 스코프. 값에는 projects, groups, issues, work_items, merge_requests, milestones, users가 포함됩니다. 추가 스코프로는 wiki_blobs, commits, blobs, notes가 있습니다.
search string Yes 검색어.
search_type string No 사용할 검색 유형. 값에는 basic, advanced, zoekt가 포함됩니다.
confidential boolean No 기밀성으로 필터링합니다. issues 및 work_items 스코프를 지원하며, 다른 스코프는 무시됩니다.
exclude_forks boolean No 검색에서 포크된 프로젝트를 제외합니다. 정확한 코드 검색에서 사용할 수 있습니다. 설정하지 않으면 포크가 제외됩니다. GitLab 18.7에서 도입되었습니다.
regex boolean No 코드 검색 시 정규 표현식을 사용합니다. 정확한 코드 검색에서 사용할 수 있습니다. 설정하지 않으면 정규 표현식이 사용됩니다. GitLab 18.9에서 도입되었습니다.
fields array of strings No 검색할 필드의 배열로, 허용되는 값은 title만 해당합니다. issues 및 merge_requests 스코프만 지원됩니다. Premium 및 Ultimate 전용.
include_archived boolean No 검색에 아카이브된 프로젝트를 포함합니다. 기본값은 false입니다. GitLab 18.7에서 도입되었습니다.
num_context_lines integer No 결과에서 각 일치 항목 주변에 포함할 컨텍스트 라인 수. 고급 검색 및 정확한 코드 검색에서만 사용할 수 있습니다. GitLab 18.11에서 도입되었습니다.
state string No 상태로 필터링합니다. issues, work_items, merge_requests 스코프를 지원하며, 다른 스코프는 무시됩니다.
type array of strings No 유형별로 작업 항목을 필터링합니다. work_items 스코프에만 적용됩니다. 사용 가능한 유형: issue, task, epic, incident, test_case, requirement, objective, key_result, ticket.
order_by string No 허용되는 값은 created_at만 해당합니다. 설정하지 않으면 기본 검색에서는 created_at 내림차순으로, 고급 검색에서는 가장 관련성 높은 문서 순으로 결과가 정렬됩니다.
sort string No 허용되는 값은 asc 또는 desc만 해당합니다. 설정하지 않으면 기본 검색에서는 created_at 내림차순으로, 고급 검색에서는 가장 관련성 높은 문서 순으로 결과가 정렬됩니다.

응답은 요청된 스코프에 따라 달라집니다.

스코프: projects#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/3/search?scope=projects&search=flight"

응답 예시:

[
  {
    "id": 6,
    "description": "Nobis sed ipsam vero quod cupiditate veritatis hic.",
    "name": "Flight",
    "name_with_namespace": "Twitter / Flight",
    "path": "flight",
    "path_with_namespace": "twitter/flight",
    "created_at": "2017-09-05T07:58:01.621Z",
    "default_branch": "main",
    "tag_list":[], //deprecated, use `topics` instead
    "topics":[],
    "ssh_url_to_repo": "ssh://jarka@localhost:2222/twitter/flight.git",
    "http_url_to_repo": "http://localhost:3000/twitter/flight.git",
    "web_url": "http://localhost:3000/twitter/flight",
    "readme_url": "http://localhost:3000/twitter/flight/-/blob/main/README.md",
    "avatar_url": null,
    "star_count": 0,
    "forks_count": 0,
    "last_activity_at": "2018-01-31T09:56:30.902Z"
  }
]

스코프: groups#

히스토리
  • GitLab 19.4에서 elasticsearch_group_search라는 기능 플래그와 함께 도입되었습니다. 기본적으로 비활성화됩니다.
Feature flag

이 스코프의 사용 가능 여부는 기능 플래그로 제어됩니다. 자세한 내용은 히스토리를 참고합니다.

이 스코프는 지정된 그룹 자체가 아니라 그 그룹의 하위 그룹을 반환합니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/3/search?scope=groups&search=flight"

응답 예시:

[
  {
    "id": 8,
    "web_url": "http://localhost:3000/groups/flightjs/flight-crew",
    "name": "Flight Crew"
  }
]

스코프: issues#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/3/search?scope=issues&search=file"

응답 예시:

[
  {
    "id": 83,
    "iid": 1,
    "project_id": 12,
    "title": "Add file",
    "description": "Add first file",
    "state": "opened",
    "created_at": "2018-01-24T06:02:15.514Z",
    "updated_at": "2018-02-06T12:36:23.263Z",
    "closed_at": null,
    "labels":[],
    "milestone": null,
    "assignees": [{
      "id": 20,
      "name": "Ceola Deckow",
      "username": "sammy.collier",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/c23d85a4f50e0ea76ab739156c639231?s=80&d=identicon",
      "web_url": "http://localhost:3000/sammy.collier"
    }],
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "assignee": {
      "id": 20,
      "name": "Ceola Deckow",
      "username": "sammy.collier",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/c23d85a4f50e0ea76ab739156c639231?s=80&d=identicon",
      "web_url": "http://localhost:3000/sammy.collier"
    },
    "user_notes_count": 0,
    "upvotes": 0,
    "downvotes": 0,
    "due_date": null,
    "confidential": false,
    "discussion_locked": null,
    "web_url": "http://localhost:3000/h5bp/7bp/subgroup-prj/issues/1",
    "time_stats": {
      "time_estimate": 0,
      "total_time_spent": 0,
      "human_time_estimate": null,
      "human_total_time_spent": null
    }
  }
]
Note

assignee 칼럼은 더 이상 사용되지 않습니다. 이제 크기가 1인 assignees 배열입니다.

스코프: work_items#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/3/search?scope=work_items&search=migrate"

응답 예시:

[
  {
    "id": 142,
    "iid": 9,
    "project_id": 12,
    "title": "Migrate to new database",
    "description": "Database migration task",
    "state": "opened",
    "created_at": "2018-03-15T08:12:31.489Z",
    "updated_at": "2018-03-20T14:22:18.371Z",
    "closed_at": null,
    "labels": ["backend"],
    "milestone": null,
    "assignees": [{
      "id": 25,
      "name": "John Doe",
      "username": "john.doe",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/a1b2c3d4e5f6g7h8i9j0?s=80&d=identicon",
      "web_url": "http://localhost:3000/john.doe"
    }],
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "type": "TASK",
    "user_notes_count": 2,
    "upvotes": 1,
    "downvotes": 0,
    "due_date": "2018-04-01",
    "confidential": false,
    "discussion_locked": null,
    "web_url": "http://localhost:3000/my-group/my-project/-/work_items/9",
    "time_stats": {
      "time_estimate": 0,
      "total_time_spent": 0,
      "human_time_estimate": null,
      "human_total_time_spent": null
    }
  }
]

type 파라미터를 사용하여 작업 항목을 유형별로 필터링할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/3/search?scope=work_items&search=backend&type[]=task&type[]=issue"

스코프: merge_requests#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/3/search?scope=merge_requests&search=file"

응답 예시:

[
  {
    "id": 56,
    "iid": 8,
    "project_id": 6,
    "title": "Add first file",
    "description": "This is a test MR to add file",
    "state": "opened",
    "created_at": "2018-01-22T14:21:50.830Z",
    "updated_at": "2018-02-06T12:40:33.295Z",
    "target_branch": "main",
    "source_branch": "jaja-test",
    "upvotes": 0,
    "downvotes": 0,
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "assignee": {
      "id": 5,
      "name": "Jacquelyn Kutch",
      "username": "abigail",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/3138c66095ee4bd11a508c2f7f7772da?s=80&d=identicon",
      "web_url": "http://localhost:3000/abigail"
    },
    "source_project_id": 6,
    "target_project_id": 6,
    "labels": [
      "ruby",
      "tests"
    ],
    "draft": false,
    "work_in_progress": false,
    "milestone": {
      "id": 13,
      "iid": 3,
      "project_id": 6,
      "title": "v2.0",
      "description": "Qui aut qui eos dolor beatae itaque tempore molestiae.",
      "state": "active",
      "created_at": "2017-09-05T07:58:29.099Z",
      "updated_at": "2017-09-05T07:58:29.099Z",
      "due_date": null,
      "start_date": null
    },
    "merge_when_pipeline_succeeds": false,
    "merge_status": "can_be_merged",
    "sha": "78765a2d5e0a43585945c58e61ba2f822e4d090b",
    "merge_commit_sha": null,
    "squash_commit_sha": null,
    "user_notes_count": 0,
    "discussion_locked": null,
    "should_remove_source_branch": null,
    "force_remove_source_branch": true,
    "web_url": "http://localhost:3000/twitter/flight/merge_requests/8",
    "time_stats": {
      "time_estimate": 0,
      "total_time_spent": 0,
      "human_time_estimate": null,
      "human_total_time_spent": null
    }
  }
]

스코프: milestones#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/3/search?scope=milestones&search=release"

응답 예시:

[
  {
    "id": 44,
    "iid": 1,
    "project_id": 12,
    "title": "next release",
    "description": "Next release milestone",
    "state": "active",
    "created_at": "2018-02-06T12:43:39.271Z",
    "updated_at": "2018-02-06T12:44:01.298Z",
    "due_date": "2018-04-18",
    "start_date": "2018-02-04"
  }
]

스코프: users#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/3/search?scope=users&search=doe"

응답 예시:

[
  {
    "id": 1,
    "name": "John Doe1",
    "username": "user1",
    "state": "active",
    "avatar_url": "http://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80&d=identicon",
    "web_url": "http://localhost/user1"
  }
]

스코프: wiki_blobs#

이 스코프를 사용하여 위키를 검색합니다.

이 스코프는 고급 검색이 활성화된 경우에만 사용할 수 있습니다.

이 스코프에서는 다음 필터를 사용할 수 있습니다.

  • filename
  • path
  • extension

필터를 사용하려면 쿼리에 해당 필터를 포함합니다(예: a query filename:some_name*).

glob 매칭에는 와일드카드(*)를 사용할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/6/search?scope=wiki_blobs&search=bye"

응답 예시:


[
  {
    "basename": "home",
    "data": "hello\n\nand bye\n\nend",
    "path": "home.md",
    "filename": "home.md",
    "id": null,
    "ref": "main",
    "startline": 5,
    "project_id": 6,
    "group_id": 1
  }
]
Note

filename은 path로 대체되어 더 이상 사용되지 않습니다. 둘 다 리포지터리 내 파일의 전체 경로를 반환하지만, 앞으로 filename은 전체 경로가 아닌 파일 이름만 나타낼 예정입니다. 자세한 내용은 이슈 34521을 참고합니다.

스코프: commits#

이 스코프는 고급 검색이 활성화된 경우에만 사용할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/6/search?scope=commits&search=bye"

응답 예시:


[
  {
  "id": "4109c2d872d5fdb1ed057400d103766aaea97f98",
  "short_id": "4109c2d8",
  "title": "goodbye $.browser",
  "created_at": "2013-02-18T22:02:54.000Z",
  "parent_ids": [
    "59d05353ab575bcc2aa958fe1782e93297de64c9"
  ],
  "message": "goodbye $.browser\n",
  "author_name": "angus croll",
  "author_email": "anguscroll@gmail.com",
  "authored_date": "2013-02-18T22:02:54.000Z",
  "committer_name": "angus croll",
  "committer_email": "anguscroll@gmail.com",
  "committed_date": "2013-02-18T22:02:54.000Z",
  "project_id": 6
  }
]

스코프: blobs#

이 스코프를 사용하여 코드를 검색합니다.

이 스코프는 고급 검색 또는 정확한 코드 검색이 활성화된 경우에만 사용할 수 있습니다.

이 스코프에서는 다음 필터를 사용할 수 있습니다.

  • filename
  • path
  • extension

필터를 사용하려면 쿼리에 해당 필터를 포함합니다(예: a query filename:some_name*).

glob 매칭에는 와일드카드(*)를 사용할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/6/search?scope=blobs&search=installation"

응답 예시:


[
  {
    "basename": "README",
    "data": "```\n\n## Installation\n\nQuick start using the [pre-built",
    "path": "README.md",
    "filename": "README.md",
    "id": null,
    "ref": "main",
    "startline": 46,
    "project_id": 6
  }
]
Note

filename은 path로 대체되어 더 이상 사용되지 않습니다. 둘 다 리포지터리 내 파일의 전체 경로를 반환하지만, 앞으로 filename은 전체 경로가 아닌 파일 이름만 나타낼 예정입니다. 자세한 내용은 이슈 34521을 참고합니다. Elasticsearch 구문은 정확한 코드 검색에서 제대로 동작하지 않을 수 있습니다. 정확한 코드 검색에서는 Elasticsearch 와일드카드 쿼리를 정규 표현식으로 대체합니다. 자세한 내용은 이슈 521686을 참고합니다.

스코프: notes#

이 스코프는 고급 검색이 활성화된 경우에만 사용할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/6/search?scope=notes&search=maxime"

응답 예시:

[
  {
    "id": 191,
    "body": "Harum maxime consequuntur et et deleniti assumenda facilis.",
    "attachment": null,
    "author": {
      "id": 23,
      "name": "User 1",
      "username": "user1",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/111d68d06e2d317b5a59c2c6c5bad808?s=80&d=identicon",
      "web_url": "http://localhost:3000/user1"
    },
    "created_at": "2017-09-05T08:01:32.068Z",
    "updated_at": "2017-09-05T08:01:32.068Z",
    "system": false,
    "noteable_id": 22,
    "noteable_type": "Issue",
    "project_id": 6,
    "noteable_iid": 2
  }
]

프로젝트 검색#

지정된 프로젝트에서 용어를 검색합니다.

사용자가 프로젝트의 멤버가 아니고 해당 프로젝트가 비공개인 경우, 해당 프로젝트에 대한 GET 요청은 404 상태 코드를 반환합니다.

GET /projects/:id/search
Attribute Type Required Description
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
scope string Yes 검색할 스코프. 값에는 issues, work_items, merge_requests, milestones, users가 포함됩니다. 추가 스코프로는 wiki_blobs, commits, blobs, notes가 있습니다.
search string Yes 검색어.
search_type string No 사용할 검색 유형. 값에는 basic, advanced, zoekt가 포함됩니다.
confidential boolean No 기밀성으로 필터링합니다. issues 및 work_items 스코프를 지원하며, 다른 스코프는 무시됩니다.
regex boolean No 코드 검색 시 정규 표현식을 사용합니다. 정확한 코드 검색에서 사용할 수 있습니다. 설정하지 않으면 정규 표현식이 사용됩니다. GitLab 18.9에서 도입되었습니다.
fields array of strings No 검색할 필드의 배열로, 허용되는 값은 title만 해당합니다. issues 및 merge_requests 스코프만 지원됩니다. Premium 및 Ultimate 전용.
num_context_lines integer No 결과에서 각 일치 항목 주변에 포함할 컨텍스트 라인 수. 고급 검색 및 정확한 코드 검색에서만 사용할 수 있습니다. GitLab 18.11에서 도입되었습니다.
ref string No 검색할 리포지터리 브랜치 또는 태그명. 기본적으로 프로젝트의 기본 브랜치가 사용됩니다. blobs, commits, wiki_blobs 스코프에만 적용됩니다.
state string No 상태로 필터링합니다. issues, work_items, merge_requests 스코프를 지원하며, 다른 스코프는 무시됩니다.
type array of strings No 유형별로 작업 항목을 필터링합니다. work_items 스코프에만 적용됩니다. 사용 가능한 유형: issue, task, epic, incident, test_case, requirement, objective, key_result, ticket.
order_by string No 허용되는 값은 created_at만 해당합니다. 설정하지 않으면 기본 검색에서는 created_at 내림차순으로, 고급 검색에서는 가장 관련성 높은 문서 순으로 결과가 정렬됩니다.
sort string No 허용되는 값은 asc 또는 desc만 해당합니다. 설정하지 않으면 기본 검색에서는 created_at 내림차순으로, 고급 검색에서는 가장 관련성 높은 문서 순으로 결과가 정렬됩니다.

응답은 요청된 스코프에 따라 달라집니다.

스코프: issues#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/12/search?scope=issues&search=file"

응답 예시:

[
  {
    "id": 83,
    "iid": 1,
    "project_id": 12,
    "title": "Add file",
    "description": "Add first file",
    "state": "opened",
    "created_at": "2018-01-24T06:02:15.514Z",
    "updated_at": "2018-02-06T12:36:23.263Z",
    "closed_at": null,
    "labels":[],
    "milestone": null,
    "assignees": [{
      "id": 20,
      "name": "Ceola Deckow",
      "username": "sammy.collier",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/c23d85a4f50e0ea76ab739156c639231?s=80&d=identicon",
      "web_url": "http://localhost:3000/sammy.collier"
    }],
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "assignee": {
      "id": 20,
      "name": "Ceola Deckow",
      "username": "sammy.collier",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/c23d85a4f50e0ea76ab739156c639231?s=80&d=identicon",
      "web_url": "http://localhost:3000/sammy.collier"
    },
    "user_notes_count": 0,
    "upvotes": 0,
    "downvotes": 0,
    "due_date": null,
    "confidential": false,
    "discussion_locked": null,
    "web_url": "http://localhost:3000/h5bp/7bp/subgroup-prj/issues/1",
    "time_stats": {
      "time_estimate": 0,
      "total_time_spent": 0,
      "human_time_estimate": null,
      "human_total_time_spent": null
    }
  }
]
Note

assignee 칼럼은 더 이상 사용되지 않습니다. 이제 크기가 1인 assignees 배열입니다.

스코프: work_items#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/12/search?scope=work_items&search=migrate"

응답 예시:

[
  {
    "id": 142,
    "iid": 9,
    "project_id": 12,
    "title": "Migrate to new database",
    "description": "Database migration task",
    "state": "opened",
    "created_at": "2018-03-15T08:12:31.489Z",
    "updated_at": "2018-03-20T14:22:18.371Z",
    "closed_at": null,
    "labels": ["backend"],
    "milestone": null,
    "assignees": [{
      "id": 25,
      "name": "John Doe",
      "username": "john.doe",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/a1b2c3d4e5f6g7h8i9j0?s=80&d=identicon",
      "web_url": "http://localhost:3000/john.doe"
    }],
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "type": "TASK",
    "user_notes_count": 2,
    "upvotes": 1,
    "downvotes": 0,
    "due_date": "2018-04-01",
    "confidential": false,
    "discussion_locked": null,
    "web_url": "http://localhost:3000/my-group/my-project/-/work_items/9",
    "time_stats": {
      "time_estimate": 0,
      "total_time_spent": 0,
      "human_time_estimate": null,
      "human_total_time_spent": null
    }
  }
]

type 파라미터를 사용하여 작업 항목을 유형별로 필터링할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/12/search?scope=work_items&search=backend&type[]=task&type[]=issue"

스코프: merge_requests#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/6/search?scope=merge_requests&search=file"

응답 예시:

[
  {
    "id": 56,
    "iid": 8,
    "project_id": 6,
    "title": "Add first file",
    "description": "This is a test MR to add file",
    "state": "opened",
    "created_at": "2018-01-22T14:21:50.830Z",
    "updated_at": "2018-02-06T12:40:33.295Z",
    "target_branch": "main",
    "source_branch": "jaja-test",
    "upvotes": 0,
    "downvotes": 0,
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "assignee": {
      "id": 5,
      "name": "Jacquelyn Kutch",
      "username": "abigail",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/3138c66095ee4bd11a508c2f7f7772da?s=80&d=identicon",
      "web_url": "http://localhost:3000/abigail"
    },
    "source_project_id": 6,
    "target_project_id": 6,
    "labels": [
      "ruby",
      "tests"
    ],
    "draft": false,
    "work_in_progress": false,
    "milestone": {
      "id": 13,
      "iid": 3,
      "project_id": 6,
      "title": "v2.0",
      "description": "Qui aut qui eos dolor beatae itaque tempore molestiae.",
      "state": "active",
      "created_at": "2017-09-05T07:58:29.099Z",
      "updated_at": "2017-09-05T07:58:29.099Z",
      "due_date": null,
      "start_date": null
    },
    "merge_when_pipeline_succeeds": false,
    "merge_status": "can_be_merged",
    "sha": "78765a2d5e0a43585945c58e61ba2f822e4d090b",
    "merge_commit_sha": null,
    "squash_commit_sha": null,
    "user_notes_count": 0,
    "discussion_locked": null,
    "should_remove_source_branch": null,
    "force_remove_source_branch": true,
    "web_url": "http://localhost:3000/twitter/flight/merge_requests/8",
    "time_stats": {
      "time_estimate": 0,
      "total_time_spent": 0,
      "human_time_estimate": null,
      "human_total_time_spent": null
    }
  }
]

스코프: milestones#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/12/search?scope=milestones&search=release"

응답 예시:

[
  {
    "id": 44,
    "iid": 1,
    "project_id": 12,
    "title": "next release",
    "description": "Next release milestone",
    "state": "active",
    "created_at": "2018-02-06T12:43:39.271Z",
    "updated_at": "2018-02-06T12:44:01.298Z",
    "due_date": "2018-04-18",
    "start_date": "2018-02-04"
  }
]

스코프: users#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/6/search?scope=users&search=doe"

응답 예시:

[
  {
    "id": 1,
    "name": "John Doe1",
    "username": "user1",
    "state": "active",
    "avatar_url": "http://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80&d=identicon",
    "web_url": "http://localhost/user1"
  }
]

스코프: wiki_blobs#

이 스코프를 사용하여 위키를 검색합니다.

이 스코프에서는 다음 필터를 사용할 수 있습니다.

  • filename
  • path
  • extension

필터를 사용하려면 쿼리에 해당 필터를 포함합니다(예: a query filename:some_name*).

glob 매칭에는 와일드카드(*)를 사용할 수 있습니다.

위키 blob 검색은 파일 이름과 콘텐츠 양쪽을 대상으로 수행됩니다. 검색 결과는 다음과 같습니다.

  • 파일 이름에서 찾은 결과가 콘텐츠에서 찾은 결과보다 먼저 표시됩니다.
  • 검색 문자열이 파일 이름과 콘텐츠 양쪽에서 발견되거나 콘텐츠 안에서 여러 번 나타날 수 있으므로, 같은 blob에 대한 일치 항목이 여러 개 포함될 수 있습니다.
curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/6/search?scope=wiki_blobs&search=bye"

응답 예시:


[
  {
    "basename": "home",
    "data": "hello\n\nand bye\n\nend",
    "path": "home.md",
    "filename": "home.md",
    "id": null,
    "ref": "main",
    "startline": 5,
    "project_id": 6,
    "group_id": 1
  }
]
Note

filename은 path로 대체되어 더 이상 사용되지 않습니다. 둘 다 리포지터리 내 파일의 전체 경로를 반환하지만, 앞으로 filename은 전체 경로가 아닌 파일 이름만 나타낼 예정입니다. 자세한 내용은 이슈 34521을 참고합니다.

스코프: commits#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/6/search?scope=commits&search=bye"

응답 예시:


[
  {
  "id": "4109c2d872d5fdb1ed057400d103766aaea97f98",
  "short_id": "4109c2d8",
  "title": "goodbye $.browser",
  "created_at": "2013-02-18T22:02:54.000Z",
  "parent_ids": [
    "59d05353ab575bcc2aa958fe1782e93297de64c9"
  ],
  "message": "goodbye $.browser\n",
  "author_name": "angus croll",
  "author_email": "anguscroll@gmail.com",
  "authored_date": "2013-02-18T22:02:54.000Z",
  "committer_name": "angus croll",
  "committer_email": "anguscroll@gmail.com",
  "committed_date": "2013-02-18T22:02:54.000Z",
  "project_id": 6
  }
]

스코프: blobs#

이 스코프를 사용하여 코드를 검색합니다.

이 스코프에서는 다음 필터를 사용할 수 있습니다.

  • filename
  • path
  • extension

필터를 사용하려면 쿼리에 해당 필터를 포함합니다(예: a query filename:some_name*).

glob 매칭에는 와일드카드(*)를 사용할 수 있습니다.

blob 검색은 파일 이름과 콘텐츠 양쪽을 대상으로 수행됩니다. 검색 결과는 다음과 같습니다.

  • 파일 이름에서 찾은 결과가 콘텐츠에서 찾은 결과보다 먼저 표시됩니다.
  • 검색 문자열이 파일 이름과 콘텐츠 양쪽에서 발견되거나 콘텐츠 안에서 여러 번 나타날 수 있으므로, 같은 blob에 대한 일치 항목이 여러 개 포함될 수 있습니다.
curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/6/search?scope=blobs&search=keyword%20filename:*.py"

응답 예시:


[
  {
    "basename": "README",
    "data": "```\n\n## Installation\n\nQuick start using the [pre-built",
    "path": "README.md",
    "filename": "README.md",
    "id": null,
    "ref": "main",
    "startline": 46,
    "project_id": 6
  }
]
Note

filename은 path로 대체되어 더 이상 사용되지 않습니다. 둘 다 리포지터리 내 파일의 전체 경로를 반환하지만, 앞으로 filename은 전체 경로가 아닌 파일 이름만 나타낼 예정입니다. 자세한 내용은 이슈 34521을 참고합니다. Elasticsearch 구문은 정확한 코드 검색에서 제대로 동작하지 않을 수 있습니다. 정확한 코드 검색에서는 Elasticsearch 와일드카드 쿼리를 정규 표현식으로 대체합니다. 자세한 내용은 이슈 521686을 참고합니다.

스코프: notes#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/6/search?scope=notes&search=maxime"

응답 예시:

[
  {
    "id": 191,
    "body": "Harum maxime consequuntur et et deleniti assumenda facilis.",
    "attachment": null,
    "author": {
      "id": 23,
      "name": "User 1",
      "username": "user1",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/111d68d06e2d317b5a59c2c6c5bad808?s=80&d=identicon",
      "web_url": "http://localhost:3000/user1"
    },
    "created_at": "2017-09-05T08:01:32.068Z",
    "updated_at": "2017-09-05T08:01:32.068Z",
    "system": false,
    "noteable_id": 22,
    "noteable_type": "Issue",
    "project_id": 6,
    "noteable_iid": 2
  }
]

시맨틱 검색#

히스토리
  • GitLab 18.11에서 semantic_code_search_rest_api라는 기능 플래그와 함께 도입되었습니다. 기본적으로 활성화됩니다.
  • GitLab 19.2에서 기능 플래그 semantic_code_search_rest_api가 제거되었습니다.

키워드 매칭이 아닌 의미를 기반으로 프로젝트에서 코드를 검색합니다.

GET /projects/:id/search/semantic
Attribute Type Required Description
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
q string Yes 자연어 검색 쿼리.
directory_path string No 검색 범위를 한정할 디렉터리 경로.
knn integer No 벡터 검색 중 고려할 최근접 이웃의 수(1-100). 기본값은 64입니다.
limit integer No 반환할 최대 결과 수(1-100). 기본값은 20입니다.

요청 예시:

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/12/search/semantic?q=authentication%20middleware"

응답 예시:

응답은 코드 검색 결과의 배열입니다. 각 결과에는 다음 필드가 포함됩니다.

Field Type Description
path string 리포지터리 루트를 기준으로 한 파일 경로.
content string 일치한 파일의 코드 콘텐츠 스니펫.
score number 쿼리와 결과 간의 의미적 유사도 점수(0-1). 점수가 높을수록 더 잘 일치함을 나타냅니다.
language string 파일의 프로그래밍 언어.
start_line integer 일치한 코드 스니펫이 시작되는 줄 번호.
blob_id string 파일의 Git blob ID.
file_url string GitLab에서 파일을 볼 수 있는 URL.
[
  {
    "path": "app/services/auth/jwt_service.rb",
    "content": "def verify_token(token)\n  JWT.decode(token, secret_key)...",
    "score": 0.91,
    "language": "ruby",
    "start_line": 42,
    "blob_id": "a1b2c3d4e5f6...",
    "file_url": "https://gitlab.example.com/my-org/my-project/-/blob/main/app/services/auth/jwt_service.rb"
  }
]

Search API

GitLab v19.4
Tier: Premium, Ultimate
Offering: GitLab.com, GitLab Self-Managed
원문 보기

요약

이 API를 사용하여 GitLab 전체에서 검색할 수 있습니다. 일부 스코프는 기본 검색에서 사용할 수 있습니다. 기본 검색을 대신 사용하려면 검색 유형 지정을 참고합니다. Search API는 오프셋 기반 페이지네이션을 지원합니다.

이 API를 사용하여 GitLab 전체에서 검색할 수 있습니다. 이 API에 대한 모든 호출에는 인증이 필요합니다.

일부 스코프는 기본 검색에서 사용할 수 있습니다. 고급 검색 또는 정확한 코드 검색이 활성화된 경우, 전역 검색, 그룹 검색, 프로젝트 검색 작업에서 추가 스코프를 사용할 수 있습니다.

기본 검색을 대신 사용하려면 검색 유형 지정을 참고합니다.

Search API는 오프셋 기반 페이지네이션을 지원합니다.

고급 검색에서는 최대 10,000건의 결과(page 곱하기 per_page)를 가져올 수 있습니다. 이 한도를 넘는 요청은 next 링크가 없는 빈 페이지를 반환하므로, 빈 응답을 받을 때까지 페이지를 넘기는 클라이언트는 이 한도에서 멈춥니다. 기본 검색과 정확한 코드 검색은 영향을 받지 않습니다. GitLab이 해당 설정을 읽지 않으므로, Elasticsearch 클러스터에서 index.max_result_window 값을 올려도 한도는 늘어나지 않습니다.

인스턴스 검색#

GitLab 인스턴스 전체에서 용어를 검색합니다. 응답은 요청된 스코프에 따라 달라집니다.

GET /search
Attribute Type Required Description
scope string Yes 검색할 스코프. 값에는 projects, groups, issues, work_items, merge_requests, milestones, snippet_titles, users가 포함됩니다. 추가 스코프로는 wiki_blobs, commits, blobs, notes가 있습니다.
search string Yes 검색어.
search_type string No 사용할 검색 유형. 값에는 basic, advanced, zoekt가 포함됩니다.
confidential boolean No 기밀성으로 필터링합니다. issues 및 work_items 스코프를 지원하며, 다른 스코프는 무시됩니다.
exclude_forks boolean No 검색에서 포크된 프로젝트를 제외합니다. 정확한 코드 검색에서 사용할 수 있습니다. 설정하지 않으면 포크가 제외됩니다. GitLab 18.7에서 도입되었습니다.
regex boolean No 코드 검색 시 정규 표현식을 사용합니다. 정확한 코드 검색에서 사용할 수 있습니다. 설정하지 않으면 정규 표현식이 사용됩니다. GitLab 18.9에서 도입되었습니다.
fields array of strings No 검색할 필드의 배열로, 허용되는 값은 title만 해당합니다. issues 및 merge_requests 스코프만 지원됩니다. Premium 및 Ultimate 전용.
include_archived boolean No 검색에 아카이브된 프로젝트를 포함합니다. 기본값은 false입니다. GitLab 18.7에서 도입되었습니다.
num_context_lines integer No 결과에서 각 일치 항목 주변에 포함할 컨텍스트 라인 수. 고급 검색 및 정확한 코드 검색에서만 사용할 수 있습니다. GitLab 18.11에서 도입되었습니다.
state string No 상태로 필터링합니다. issues, work_items, merge_requests 스코프를 지원하며, 다른 스코프는 무시됩니다.
type array of strings No 유형별로 작업 항목을 필터링합니다. work_items 스코프에만 적용됩니다. 사용 가능한 유형: issue, task, epic, incident, test_case, requirement, objective, key_result, ticket.
order_by string No 허용되는 값은 created_at만 해당합니다. 설정하지 않으면 기본 검색에서는 created_at 내림차순으로, 고급 검색에서는 가장 관련성 높은 문서 순으로 결과가 정렬됩니다.
sort string No 허용되는 값은 asc 또는 desc만 해당합니다. 설정하지 않으면 기본 검색에서는 created_at 내림차순으로, 고급 검색에서는 가장 관련성 높은 문서 순으로 결과가 정렬됩니다.

스코프: projects#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=projects&search=flight"

응답 예시:

[
  {
    "id": 6,
    "description": "Nobis sed ipsam vero quod cupiditate veritatis hic.",
    "name": "Flight",
    "name_with_namespace": "Twitter / Flight",
    "path": "flight",
    "path_with_namespace": "twitter/flight",
    "created_at": "2017-09-05T07:58:01.621Z",
    "default_branch": "main",
    "tag_list":[], //deprecated, use `topics` instead
    "topics":[],
    "ssh_url_to_repo": "ssh://jarka@localhost:2222/twitter/flight.git",
    "http_url_to_repo": "http://localhost:3000/twitter/flight.git",
    "web_url": "http://localhost:3000/twitter/flight",
    "readme_url": "http://localhost:3000/twitter/flight/-/blob/main/README.md",
    "avatar_url": null,
    "star_count": 0,
    "forks_count": 0,
    "last_activity_at": "2018-01-31T09:56:30.902Z"
  }
]

스코프: groups#

히스토리
  • GitLab 19.4에서 elasticsearch_group_search라는 기능 플래그와 함께 도입되었습니다. 기본적으로 비활성화됩니다.
Feature flag

이 스코프의 사용 가능 여부는 기능 플래그로 제어됩니다. 자세한 내용은 히스토리를 참고합니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=groups&search=flight"

응답 예시:

[
  {
    "id": 3,
    "web_url": "http://localhost:3000/groups/flightjs",
    "name": "Flightjs"
  }
]

스코프: issues#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=issues&search=file"

응답 예시:

[
  {
    "id": 83,
    "iid": 1,
    "project_id": 12,
    "title": "Add file",
    "description": "Add first file",
    "state": "opened",
    "created_at": "2018-01-24T06:02:15.514Z",
    "updated_at": "2018-02-06T12:36:23.263Z",
    "closed_at": null,
    "labels":[],
    "milestone": null,
    "assignees": [{
      "id": 20,
      "name": "Ceola Deckow",
      "username": "sammy.collier",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/c23d85a4f50e0ea76ab739156c639231?s=80&d=identicon",
      "web_url": "http://localhost:3000/sammy.collier"
    }],
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "assignee": {
      "id": 20,
      "name": "Ceola Deckow",
      "username": "sammy.collier",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/c23d85a4f50e0ea76ab739156c639231?s=80&d=identicon",
      "web_url": "http://localhost:3000/sammy.collier"
    },
    "user_notes_count": 0,
    "upvotes": 0,
    "downvotes": 0,
    "due_date": null,
    "confidential": false,
    "discussion_locked": null,
    "web_url": "http://localhost:3000/h5bp/7bp/subgroup-prj/issues/1",
    "time_stats": {
      "time_estimate": 0,
      "total_time_spent": 0,
      "human_time_estimate": null,
      "human_total_time_spent": null
    }
  }
]
Note

assignee 칼럼은 더 이상 사용되지 않습니다. GitLab EE API를 따르기 위해 크기가 1인 배열 assignees로 표시됩니다.

스코프: work_items#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=work_items&search=migrate"

응답 예시:

[
  {
    "id": 142,
    "iid": 9,
    "project_id": 12,
    "title": "Migrate to new database",
    "description": "Database migration task",
    "state": "opened",
    "created_at": "2018-03-15T08:12:31.489Z",
    "updated_at": "2018-03-20T14:22:18.371Z",
    "closed_at": null,
    "labels": ["backend"],
    "milestone": null,
    "assignees": [{
      "id": 25,
      "name": "John Doe",
      "username": "john.doe",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/a1b2c3d4e5f6g7h8i9j0?s=80&d=identicon",
      "web_url": "http://localhost:3000/john.doe"
    }],
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "type": "TASK",
    "user_notes_count": 2,
    "upvotes": 1,
    "downvotes": 0,
    "due_date": "2018-04-01",
    "confidential": false,
    "discussion_locked": null,
    "web_url": "http://localhost:3000/my-group/my-project/-/work_items/9",
    "time_stats": {
      "time_estimate": 0,
      "total_time_spent": 0,
      "human_time_estimate": null,
      "human_total_time_spent": null
    }
  }
]

type 파라미터를 사용하여 작업 항목을 유형별로 필터링할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=work_items&search=backend&type[]=task&type[]=issue"

스코프: merge_requests#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=merge_requests&search=file"

응답 예시:

[
  {
    "id": 56,
    "iid": 8,
    "project_id": 6,
    "title": "Add first file",
    "description": "This is a test MR to add file",
    "state": "opened",
    "created_at": "2018-01-22T14:21:50.830Z",
    "updated_at": "2018-02-06T12:40:33.295Z",
    "target_branch": "main",
    "source_branch": "jaja-test",
    "upvotes": 0,
    "downvotes": 0,
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "assignee": {
      "id": 5,
      "name": "Jacquelyn Kutch",
      "username": "abigail",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/3138c66095ee4bd11a508c2f7f7772da?s=80&d=identicon",
      "web_url": "http://localhost:3000/abigail"
    },
    "source_project_id": 6,
    "target_project_id": 6,
    "labels": [
      "ruby",
      "tests"
    ],
    "draft": false,
    "work_in_progress": false,
    "milestone": {
      "id": 13,
      "iid": 3,
      "project_id": 6,
      "title": "v2.0",
      "description": "Qui aut qui eos dolor beatae itaque tempore molestiae.",
      "state": "active",
      "created_at": "2017-09-05T07:58:29.099Z",
      "updated_at": "2017-09-05T07:58:29.099Z",
      "due_date": null,
      "start_date": null
    },
    "merge_when_pipeline_succeeds": false,
    "merge_status": "can_be_merged",
    "sha": "78765a2d5e0a43585945c58e61ba2f822e4d090b",
    "merge_commit_sha": null,
    "squash_commit_sha": null,
    "user_notes_count": 0,
    "discussion_locked": null,
    "should_remove_source_branch": null,
    "force_remove_source_branch": true,
    "web_url": "http://localhost:3000/twitter/flight/merge_requests/8",
    "time_stats": {
      "time_estimate": 0,
      "total_time_spent": 0,
      "human_time_estimate": null,
      "human_total_time_spent": null
    }
  }
]

스코프: milestones#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=milestones&search=release"

응답 예시:

[
  {
    "id": 44,
    "iid": 1,
    "project_id": 12,
    "title": "next release",
    "description": "Next release milestone",
    "state": "active",
    "created_at": "2018-02-06T12:43:39.271Z",
    "updated_at": "2018-02-06T12:44:01.298Z",
    "due_date": "2018-04-18",
    "start_date": "2018-02-04"
  }
]

스코프: snippet_titles#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=snippet_titles&search=sample"

응답 예시:

[
  {
    "id": 50,
    "title": "Sample file",
    "file_name": "file.rb",
    "description": "Simple ruby file",
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "updated_at": "2018-02-06T12:49:29.104Z",
    "created_at": "2017-11-28T08:20:18.071Z",
    "project_id": 9,
    "web_url": "http://localhost:3000/root/jira-test/snippets/50"
  }
]

스코프: users#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=users&search=doe"

응답 예시:

[
  {
    "id": 1,
    "name": "John Doe1",
    "username": "user1",
    "state": "active",
    "avatar_url": "http://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80&d=identicon",
    "web_url": "http://localhost/user1"
  }
]

스코프: wiki_blobs#

이 스코프를 사용하여 위키를 검색합니다.

이 스코프는 고급 검색이 활성화된 경우에만 사용할 수 있습니다.

이 스코프에서는 다음 필터를 사용할 수 있습니다.

  • filename
  • path
  • extension

필터를 사용하려면 쿼리에 해당 필터를 포함합니다(예: a query filename:some_name*).

glob 매칭에는 와일드카드(*)를 사용할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=wiki_blobs&search=bye"

응답 예시:


[
  {
    "basename": "home",
    "data": "hello\n\nand bye\n\nend",
    "path": "home.md",
    "filename": "home.md",
    "id": null,
    "ref": "main",
    "startline": 5,
    "project_id": 6,
    "group_id": null
  }
]
Note

filename은 path로 대체되어 더 이상 사용되지 않습니다. 둘 다 리포지터리 내 파일의 전체 경로를 반환하지만, 앞으로 filename은 전체 경로가 아닌 파일 이름만 나타낼 예정입니다. 자세한 내용은 이슈 34521을 참고합니다.

스코프: commits#

이 스코프는 고급 검색이 활성화된 경우에만 사용할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=commits&search=bye"

응답 예시:


[
  {
  "id": "4109c2d872d5fdb1ed057400d103766aaea97f98",
  "short_id": "4109c2d8",
  "title": "goodbye $.browser",
  "created_at": "2013-02-18T22:02:54.000Z",
  "parent_ids": [
    "59d05353ab575bcc2aa958fe1782e93297de64c9"
  ],
  "message": "goodbye $.browser\n",
  "author_name": "angus croll",
  "author_email": "anguscroll@gmail.com",
  "authored_date": "2013-02-18T22:02:54.000Z",
  "committer_name": "angus croll",
  "committer_email": "anguscroll@gmail.com",
  "committed_date": "2013-02-18T22:02:54.000Z",
  "project_id": 6
  }
]

스코프: blobs#

이 스코프를 사용하여 코드를 검색합니다.

이 스코프는 고급 검색 또는 정확한 코드 검색이 활성화된 경우에만 사용할 수 있습니다.

이 스코프에서는 다음 필터를 사용할 수 있습니다.

  • filename
  • path
  • extension

필터를 사용하려면 쿼리에 해당 필터를 포함합니다(예: a query filename:some_name*).

glob 매칭에는 와일드카드(*)를 사용할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=blobs&search=installation"

응답 예시:


[
  {
    "basename": "README",
    "data": "```\n\n## Installation\n\nQuick start using the [pre-built",
    "path": "README.md",
    "filename": "README.md",
    "id": null,
    "ref": "main",
    "startline": 46,
    "project_id": 6
  }
]
Note

filename은 path로 대체되어 더 이상 사용되지 않습니다. 둘 다 리포지터리 내 파일의 전체 경로를 반환하지만, 앞으로 filename은 전체 경로가 아닌 파일 이름만 나타낼 예정입니다. 자세한 내용은 이슈 34521을 참고합니다. Elasticsearch 구문은 정확한 코드 검색에서 제대로 동작하지 않을 수 있습니다. 정확한 코드 검색에서는 Elasticsearch 와일드카드 쿼리를 정규 표현식으로 대체합니다. 자세한 내용은 이슈 521686을 참고합니다.

스코프: notes#

이 스코프는 고급 검색이 활성화된 경우에만 사용할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/search?scope=notes&search=maxime"

응답 예시:

[
  {
    "id": 191,
    "body": "Harum maxime consequuntur et et deleniti assumenda facilis.",
    "attachment": null,
    "author": {
      "id": 23,
      "name": "User 1",
      "username": "user1",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/111d68d06e2d317b5a59c2c6c5bad808?s=80&d=identicon",
      "web_url": "http://localhost:3000/user1"
    },
    "created_at": "2017-09-05T08:01:32.068Z",
    "updated_at": "2017-09-05T08:01:32.068Z",
    "system": false,
    "noteable_id": 22,
    "noteable_type": "Issue",
    "project_id": 6,
    "noteable_iid": 2
  }
]

그룹 검색#

지정된 그룹에서 용어를 검색합니다.

사용자가 그룹의 멤버가 아니고 해당 그룹이 비공개인 경우, 해당 그룹에 대한 GET 요청은 404 Not Found 상태 코드를 반환합니다.

GET /groups/:id/search
Attribute Type Required Description
id integer or string Yes 그룹의 ID 또는 URL 인코딩된 경로.
scope string Yes 검색할 스코프. 값에는 projects, groups, issues, work_items, merge_requests, milestones, users가 포함됩니다. 추가 스코프로는 wiki_blobs, commits, blobs, notes가 있습니다.
search string Yes 검색어.
search_type string No 사용할 검색 유형. 값에는 basic, advanced, zoekt가 포함됩니다.
confidential boolean No 기밀성으로 필터링합니다. issues 및 work_items 스코프를 지원하며, 다른 스코프는 무시됩니다.
exclude_forks boolean No 검색에서 포크된 프로젝트를 제외합니다. 정확한 코드 검색에서 사용할 수 있습니다. 설정하지 않으면 포크가 제외됩니다. GitLab 18.7에서 도입되었습니다.
regex boolean No 코드 검색 시 정규 표현식을 사용합니다. 정확한 코드 검색에서 사용할 수 있습니다. 설정하지 않으면 정규 표현식이 사용됩니다. GitLab 18.9에서 도입되었습니다.
fields array of strings No 검색할 필드의 배열로, 허용되는 값은 title만 해당합니다. issues 및 merge_requests 스코프만 지원됩니다. Premium 및 Ultimate 전용.
include_archived boolean No 검색에 아카이브된 프로젝트를 포함합니다. 기본값은 false입니다. GitLab 18.7에서 도입되었습니다.
num_context_lines integer No 결과에서 각 일치 항목 주변에 포함할 컨텍스트 라인 수. 고급 검색 및 정확한 코드 검색에서만 사용할 수 있습니다. GitLab 18.11에서 도입되었습니다.
state string No 상태로 필터링합니다. issues, work_items, merge_requests 스코프를 지원하며, 다른 스코프는 무시됩니다.
type array of strings No 유형별로 작업 항목을 필터링합니다. work_items 스코프에만 적용됩니다. 사용 가능한 유형: issue, task, epic, incident, test_case, requirement, objective, key_result, ticket.
order_by string No 허용되는 값은 created_at만 해당합니다. 설정하지 않으면 기본 검색에서는 created_at 내림차순으로, 고급 검색에서는 가장 관련성 높은 문서 순으로 결과가 정렬됩니다.
sort string No 허용되는 값은 asc 또는 desc만 해당합니다. 설정하지 않으면 기본 검색에서는 created_at 내림차순으로, 고급 검색에서는 가장 관련성 높은 문서 순으로 결과가 정렬됩니다.

응답은 요청된 스코프에 따라 달라집니다.

스코프: projects#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/3/search?scope=projects&search=flight"

응답 예시:

[
  {
    "id": 6,
    "description": "Nobis sed ipsam vero quod cupiditate veritatis hic.",
    "name": "Flight",
    "name_with_namespace": "Twitter / Flight",
    "path": "flight",
    "path_with_namespace": "twitter/flight",
    "created_at": "2017-09-05T07:58:01.621Z",
    "default_branch": "main",
    "tag_list":[], //deprecated, use `topics` instead
    "topics":[],
    "ssh_url_to_repo": "ssh://jarka@localhost:2222/twitter/flight.git",
    "http_url_to_repo": "http://localhost:3000/twitter/flight.git",
    "web_url": "http://localhost:3000/twitter/flight",
    "readme_url": "http://localhost:3000/twitter/flight/-/blob/main/README.md",
    "avatar_url": null,
    "star_count": 0,
    "forks_count": 0,
    "last_activity_at": "2018-01-31T09:56:30.902Z"
  }
]

스코프: groups#

히스토리
  • GitLab 19.4에서 elasticsearch_group_search라는 기능 플래그와 함께 도입되었습니다. 기본적으로 비활성화됩니다.
Feature flag

이 스코프의 사용 가능 여부는 기능 플래그로 제어됩니다. 자세한 내용은 히스토리를 참고합니다.

이 스코프는 지정된 그룹 자체가 아니라 그 그룹의 하위 그룹을 반환합니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/3/search?scope=groups&search=flight"

응답 예시:

[
  {
    "id": 8,
    "web_url": "http://localhost:3000/groups/flightjs/flight-crew",
    "name": "Flight Crew"
  }
]

스코프: issues#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/3/search?scope=issues&search=file"

응답 예시:

[
  {
    "id": 83,
    "iid": 1,
    "project_id": 12,
    "title": "Add file",
    "description": "Add first file",
    "state": "opened",
    "created_at": "2018-01-24T06:02:15.514Z",
    "updated_at": "2018-02-06T12:36:23.263Z",
    "closed_at": null,
    "labels":[],
    "milestone": null,
    "assignees": [{
      "id": 20,
      "name": "Ceola Deckow",
      "username": "sammy.collier",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/c23d85a4f50e0ea76ab739156c639231?s=80&d=identicon",
      "web_url": "http://localhost:3000/sammy.collier"
    }],
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "assignee": {
      "id": 20,
      "name": "Ceola Deckow",
      "username": "sammy.collier",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/c23d85a4f50e0ea76ab739156c639231?s=80&d=identicon",
      "web_url": "http://localhost:3000/sammy.collier"
    },
    "user_notes_count": 0,
    "upvotes": 0,
    "downvotes": 0,
    "due_date": null,
    "confidential": false,
    "discussion_locked": null,
    "web_url": "http://localhost:3000/h5bp/7bp/subgroup-prj/issues/1",
    "time_stats": {
      "time_estimate": 0,
      "total_time_spent": 0,
      "human_time_estimate": null,
      "human_total_time_spent": null
    }
  }
]
Note

assignee 칼럼은 더 이상 사용되지 않습니다. 이제 크기가 1인 assignees 배열입니다.

스코프: work_items#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/3/search?scope=work_items&search=migrate"

응답 예시:

[
  {
    "id": 142,
    "iid": 9,
    "project_id": 12,
    "title": "Migrate to new database",
    "description": "Database migration task",
    "state": "opened",
    "created_at": "2018-03-15T08:12:31.489Z",
    "updated_at": "2018-03-20T14:22:18.371Z",
    "closed_at": null,
    "labels": ["backend"],
    "milestone": null,
    "assignees": [{
      "id": 25,
      "name": "John Doe",
      "username": "john.doe",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/a1b2c3d4e5f6g7h8i9j0?s=80&d=identicon",
      "web_url": "http://localhost:3000/john.doe"
    }],
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "type": "TASK",
    "user_notes_count": 2,
    "upvotes": 1,
    "downvotes": 0,
    "due_date": "2018-04-01",
    "confidential": false,
    "discussion_locked": null,
    "web_url": "http://localhost:3000/my-group/my-project/-/work_items/9",
    "time_stats": {
      "time_estimate": 0,
      "total_time_spent": 0,
      "human_time_estimate": null,
      "human_total_time_spent": null
    }
  }
]

type 파라미터를 사용하여 작업 항목을 유형별로 필터링할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/3/search?scope=work_items&search=backend&type[]=task&type[]=issue"

스코프: merge_requests#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/3/search?scope=merge_requests&search=file"

응답 예시:

[
  {
    "id": 56,
    "iid": 8,
    "project_id": 6,
    "title": "Add first file",
    "description": "This is a test MR to add file",
    "state": "opened",
    "created_at": "2018-01-22T14:21:50.830Z",
    "updated_at": "2018-02-06T12:40:33.295Z",
    "target_branch": "main",
    "source_branch": "jaja-test",
    "upvotes": 0,
    "downvotes": 0,
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "assignee": {
      "id": 5,
      "name": "Jacquelyn Kutch",
      "username": "abigail",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/3138c66095ee4bd11a508c2f7f7772da?s=80&d=identicon",
      "web_url": "http://localhost:3000/abigail"
    },
    "source_project_id": 6,
    "target_project_id": 6,
    "labels": [
      "ruby",
      "tests"
    ],
    "draft": false,
    "work_in_progress": false,
    "milestone": {
      "id": 13,
      "iid": 3,
      "project_id": 6,
      "title": "v2.0",
      "description": "Qui aut qui eos dolor beatae itaque tempore molestiae.",
      "state": "active",
      "created_at": "2017-09-05T07:58:29.099Z",
      "updated_at": "2017-09-05T07:58:29.099Z",
      "due_date": null,
      "start_date": null
    },
    "merge_when_pipeline_succeeds": false,
    "merge_status": "can_be_merged",
    "sha": "78765a2d5e0a43585945c58e61ba2f822e4d090b",
    "merge_commit_sha": null,
    "squash_commit_sha": null,
    "user_notes_count": 0,
    "discussion_locked": null,
    "should_remove_source_branch": null,
    "force_remove_source_branch": true,
    "web_url": "http://localhost:3000/twitter/flight/merge_requests/8",
    "time_stats": {
      "time_estimate": 0,
      "total_time_spent": 0,
      "human_time_estimate": null,
      "human_total_time_spent": null
    }
  }
]

스코프: milestones#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/3/search?scope=milestones&search=release"

응답 예시:

[
  {
    "id": 44,
    "iid": 1,
    "project_id": 12,
    "title": "next release",
    "description": "Next release milestone",
    "state": "active",
    "created_at": "2018-02-06T12:43:39.271Z",
    "updated_at": "2018-02-06T12:44:01.298Z",
    "due_date": "2018-04-18",
    "start_date": "2018-02-04"
  }
]

스코프: users#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/3/search?scope=users&search=doe"

응답 예시:

[
  {
    "id": 1,
    "name": "John Doe1",
    "username": "user1",
    "state": "active",
    "avatar_url": "http://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80&d=identicon",
    "web_url": "http://localhost/user1"
  }
]

스코프: wiki_blobs#

이 스코프를 사용하여 위키를 검색합니다.

이 스코프는 고급 검색이 활성화된 경우에만 사용할 수 있습니다.

이 스코프에서는 다음 필터를 사용할 수 있습니다.

  • filename
  • path
  • extension

필터를 사용하려면 쿼리에 해당 필터를 포함합니다(예: a query filename:some_name*).

glob 매칭에는 와일드카드(*)를 사용할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/6/search?scope=wiki_blobs&search=bye"

응답 예시:


[
  {
    "basename": "home",
    "data": "hello\n\nand bye\n\nend",
    "path": "home.md",
    "filename": "home.md",
    "id": null,
    "ref": "main",
    "startline": 5,
    "project_id": 6,
    "group_id": 1
  }
]
Note

filename은 path로 대체되어 더 이상 사용되지 않습니다. 둘 다 리포지터리 내 파일의 전체 경로를 반환하지만, 앞으로 filename은 전체 경로가 아닌 파일 이름만 나타낼 예정입니다. 자세한 내용은 이슈 34521을 참고합니다.

스코프: commits#

이 스코프는 고급 검색이 활성화된 경우에만 사용할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/6/search?scope=commits&search=bye"

응답 예시:


[
  {
  "id": "4109c2d872d5fdb1ed057400d103766aaea97f98",
  "short_id": "4109c2d8",
  "title": "goodbye $.browser",
  "created_at": "2013-02-18T22:02:54.000Z",
  "parent_ids": [
    "59d05353ab575bcc2aa958fe1782e93297de64c9"
  ],
  "message": "goodbye $.browser\n",
  "author_name": "angus croll",
  "author_email": "anguscroll@gmail.com",
  "authored_date": "2013-02-18T22:02:54.000Z",
  "committer_name": "angus croll",
  "committer_email": "anguscroll@gmail.com",
  "committed_date": "2013-02-18T22:02:54.000Z",
  "project_id": 6
  }
]

스코프: blobs#

이 스코프를 사용하여 코드를 검색합니다.

이 스코프는 고급 검색 또는 정확한 코드 검색이 활성화된 경우에만 사용할 수 있습니다.

이 스코프에서는 다음 필터를 사용할 수 있습니다.

  • filename
  • path
  • extension

필터를 사용하려면 쿼리에 해당 필터를 포함합니다(예: a query filename:some_name*).

glob 매칭에는 와일드카드(*)를 사용할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/6/search?scope=blobs&search=installation"

응답 예시:


[
  {
    "basename": "README",
    "data": "```\n\n## Installation\n\nQuick start using the [pre-built",
    "path": "README.md",
    "filename": "README.md",
    "id": null,
    "ref": "main",
    "startline": 46,
    "project_id": 6
  }
]
Note

filename은 path로 대체되어 더 이상 사용되지 않습니다. 둘 다 리포지터리 내 파일의 전체 경로를 반환하지만, 앞으로 filename은 전체 경로가 아닌 파일 이름만 나타낼 예정입니다. 자세한 내용은 이슈 34521을 참고합니다. Elasticsearch 구문은 정확한 코드 검색에서 제대로 동작하지 않을 수 있습니다. 정확한 코드 검색에서는 Elasticsearch 와일드카드 쿼리를 정규 표현식으로 대체합니다. 자세한 내용은 이슈 521686을 참고합니다.

스코프: notes#

이 스코프는 고급 검색이 활성화된 경우에만 사용할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/groups/6/search?scope=notes&search=maxime"

응답 예시:

[
  {
    "id": 191,
    "body": "Harum maxime consequuntur et et deleniti assumenda facilis.",
    "attachment": null,
    "author": {
      "id": 23,
      "name": "User 1",
      "username": "user1",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/111d68d06e2d317b5a59c2c6c5bad808?s=80&d=identicon",
      "web_url": "http://localhost:3000/user1"
    },
    "created_at": "2017-09-05T08:01:32.068Z",
    "updated_at": "2017-09-05T08:01:32.068Z",
    "system": false,
    "noteable_id": 22,
    "noteable_type": "Issue",
    "project_id": 6,
    "noteable_iid": 2
  }
]

프로젝트 검색#

지정된 프로젝트에서 용어를 검색합니다.

사용자가 프로젝트의 멤버가 아니고 해당 프로젝트가 비공개인 경우, 해당 프로젝트에 대한 GET 요청은 404 상태 코드를 반환합니다.

GET /projects/:id/search
Attribute Type Required Description
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
scope string Yes 검색할 스코프. 값에는 issues, work_items, merge_requests, milestones, users가 포함됩니다. 추가 스코프로는 wiki_blobs, commits, blobs, notes가 있습니다.
search string Yes 검색어.
search_type string No 사용할 검색 유형. 값에는 basic, advanced, zoekt가 포함됩니다.
confidential boolean No 기밀성으로 필터링합니다. issues 및 work_items 스코프를 지원하며, 다른 스코프는 무시됩니다.
regex boolean No 코드 검색 시 정규 표현식을 사용합니다. 정확한 코드 검색에서 사용할 수 있습니다. 설정하지 않으면 정규 표현식이 사용됩니다. GitLab 18.9에서 도입되었습니다.
fields array of strings No 검색할 필드의 배열로, 허용되는 값은 title만 해당합니다. issues 및 merge_requests 스코프만 지원됩니다. Premium 및 Ultimate 전용.
num_context_lines integer No 결과에서 각 일치 항목 주변에 포함할 컨텍스트 라인 수. 고급 검색 및 정확한 코드 검색에서만 사용할 수 있습니다. GitLab 18.11에서 도입되었습니다.
ref string No 검색할 리포지터리 브랜치 또는 태그명. 기본적으로 프로젝트의 기본 브랜치가 사용됩니다. blobs, commits, wiki_blobs 스코프에만 적용됩니다.
state string No 상태로 필터링합니다. issues, work_items, merge_requests 스코프를 지원하며, 다른 스코프는 무시됩니다.
type array of strings No 유형별로 작업 항목을 필터링합니다. work_items 스코프에만 적용됩니다. 사용 가능한 유형: issue, task, epic, incident, test_case, requirement, objective, key_result, ticket.
order_by string No 허용되는 값은 created_at만 해당합니다. 설정하지 않으면 기본 검색에서는 created_at 내림차순으로, 고급 검색에서는 가장 관련성 높은 문서 순으로 결과가 정렬됩니다.
sort string No 허용되는 값은 asc 또는 desc만 해당합니다. 설정하지 않으면 기본 검색에서는 created_at 내림차순으로, 고급 검색에서는 가장 관련성 높은 문서 순으로 결과가 정렬됩니다.

응답은 요청된 스코프에 따라 달라집니다.

스코프: issues#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/12/search?scope=issues&search=file"

응답 예시:

[
  {
    "id": 83,
    "iid": 1,
    "project_id": 12,
    "title": "Add file",
    "description": "Add first file",
    "state": "opened",
    "created_at": "2018-01-24T06:02:15.514Z",
    "updated_at": "2018-02-06T12:36:23.263Z",
    "closed_at": null,
    "labels":[],
    "milestone": null,
    "assignees": [{
      "id": 20,
      "name": "Ceola Deckow",
      "username": "sammy.collier",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/c23d85a4f50e0ea76ab739156c639231?s=80&d=identicon",
      "web_url": "http://localhost:3000/sammy.collier"
    }],
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "assignee": {
      "id": 20,
      "name": "Ceola Deckow",
      "username": "sammy.collier",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/c23d85a4f50e0ea76ab739156c639231?s=80&d=identicon",
      "web_url": "http://localhost:3000/sammy.collier"
    },
    "user_notes_count": 0,
    "upvotes": 0,
    "downvotes": 0,
    "due_date": null,
    "confidential": false,
    "discussion_locked": null,
    "web_url": "http://localhost:3000/h5bp/7bp/subgroup-prj/issues/1",
    "time_stats": {
      "time_estimate": 0,
      "total_time_spent": 0,
      "human_time_estimate": null,
      "human_total_time_spent": null
    }
  }
]
Note

assignee 칼럼은 더 이상 사용되지 않습니다. 이제 크기가 1인 assignees 배열입니다.

스코프: work_items#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/12/search?scope=work_items&search=migrate"

응답 예시:

[
  {
    "id": 142,
    "iid": 9,
    "project_id": 12,
    "title": "Migrate to new database",
    "description": "Database migration task",
    "state": "opened",
    "created_at": "2018-03-15T08:12:31.489Z",
    "updated_at": "2018-03-20T14:22:18.371Z",
    "closed_at": null,
    "labels": ["backend"],
    "milestone": null,
    "assignees": [{
      "id": 25,
      "name": "John Doe",
      "username": "john.doe",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/a1b2c3d4e5f6g7h8i9j0?s=80&d=identicon",
      "web_url": "http://localhost:3000/john.doe"
    }],
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "type": "TASK",
    "user_notes_count": 2,
    "upvotes": 1,
    "downvotes": 0,
    "due_date": "2018-04-01",
    "confidential": false,
    "discussion_locked": null,
    "web_url": "http://localhost:3000/my-group/my-project/-/work_items/9",
    "time_stats": {
      "time_estimate": 0,
      "total_time_spent": 0,
      "human_time_estimate": null,
      "human_total_time_spent": null
    }
  }
]

type 파라미터를 사용하여 작업 항목을 유형별로 필터링할 수 있습니다.

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/12/search?scope=work_items&search=backend&type[]=task&type[]=issue"

스코프: merge_requests#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/6/search?scope=merge_requests&search=file"

응답 예시:

[
  {
    "id": 56,
    "iid": 8,
    "project_id": 6,
    "title": "Add first file",
    "description": "This is a test MR to add file",
    "state": "opened",
    "created_at": "2018-01-22T14:21:50.830Z",
    "updated_at": "2018-02-06T12:40:33.295Z",
    "target_branch": "main",
    "source_branch": "jaja-test",
    "upvotes": 0,
    "downvotes": 0,
    "author": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://localhost:3000/root"
    },
    "assignee": {
      "id": 5,
      "name": "Jacquelyn Kutch",
      "username": "abigail",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/3138c66095ee4bd11a508c2f7f7772da?s=80&d=identicon",
      "web_url": "http://localhost:3000/abigail"
    },
    "source_project_id": 6,
    "target_project_id": 6,
    "labels": [
      "ruby",
      "tests"
    ],
    "draft": false,
    "work_in_progress": false,
    "milestone": {
      "id": 13,
      "iid": 3,
      "project_id": 6,
      "title": "v2.0",
      "description": "Qui aut qui eos dolor beatae itaque tempore molestiae.",
      "state": "active",
      "created_at": "2017-09-05T07:58:29.099Z",
      "updated_at": "2017-09-05T07:58:29.099Z",
      "due_date": null,
      "start_date": null
    },
    "merge_when_pipeline_succeeds": false,
    "merge_status": "can_be_merged",
    "sha": "78765a2d5e0a43585945c58e61ba2f822e4d090b",
    "merge_commit_sha": null,
    "squash_commit_sha": null,
    "user_notes_count": 0,
    "discussion_locked": null,
    "should_remove_source_branch": null,
    "force_remove_source_branch": true,
    "web_url": "http://localhost:3000/twitter/flight/merge_requests/8",
    "time_stats": {
      "time_estimate": 0,
      "total_time_spent": 0,
      "human_time_estimate": null,
      "human_total_time_spent": null
    }
  }
]

스코프: milestones#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/12/search?scope=milestones&search=release"

응답 예시:

[
  {
    "id": 44,
    "iid": 1,
    "project_id": 12,
    "title": "next release",
    "description": "Next release milestone",
    "state": "active",
    "created_at": "2018-02-06T12:43:39.271Z",
    "updated_at": "2018-02-06T12:44:01.298Z",
    "due_date": "2018-04-18",
    "start_date": "2018-02-04"
  }
]

스코프: users#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/6/search?scope=users&search=doe"

응답 예시:

[
  {
    "id": 1,
    "name": "John Doe1",
    "username": "user1",
    "state": "active",
    "avatar_url": "http://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80&d=identicon",
    "web_url": "http://localhost/user1"
  }
]

스코프: wiki_blobs#

이 스코프를 사용하여 위키를 검색합니다.

이 스코프에서는 다음 필터를 사용할 수 있습니다.

  • filename
  • path
  • extension

필터를 사용하려면 쿼리에 해당 필터를 포함합니다(예: a query filename:some_name*).

glob 매칭에는 와일드카드(*)를 사용할 수 있습니다.

위키 blob 검색은 파일 이름과 콘텐츠 양쪽을 대상으로 수행됩니다. 검색 결과는 다음과 같습니다.

  • 파일 이름에서 찾은 결과가 콘텐츠에서 찾은 결과보다 먼저 표시됩니다.
  • 검색 문자열이 파일 이름과 콘텐츠 양쪽에서 발견되거나 콘텐츠 안에서 여러 번 나타날 수 있으므로, 같은 blob에 대한 일치 항목이 여러 개 포함될 수 있습니다.
curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/6/search?scope=wiki_blobs&search=bye"

응답 예시:


[
  {
    "basename": "home",
    "data": "hello\n\nand bye\n\nend",
    "path": "home.md",
    "filename": "home.md",
    "id": null,
    "ref": "main",
    "startline": 5,
    "project_id": 6,
    "group_id": 1
  }
]
Note

filename은 path로 대체되어 더 이상 사용되지 않습니다. 둘 다 리포지터리 내 파일의 전체 경로를 반환하지만, 앞으로 filename은 전체 경로가 아닌 파일 이름만 나타낼 예정입니다. 자세한 내용은 이슈 34521을 참고합니다.

스코프: commits#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/6/search?scope=commits&search=bye"

응답 예시:


[
  {
  "id": "4109c2d872d5fdb1ed057400d103766aaea97f98",
  "short_id": "4109c2d8",
  "title": "goodbye $.browser",
  "created_at": "2013-02-18T22:02:54.000Z",
  "parent_ids": [
    "59d05353ab575bcc2aa958fe1782e93297de64c9"
  ],
  "message": "goodbye $.browser\n",
  "author_name": "angus croll",
  "author_email": "anguscroll@gmail.com",
  "authored_date": "2013-02-18T22:02:54.000Z",
  "committer_name": "angus croll",
  "committer_email": "anguscroll@gmail.com",
  "committed_date": "2013-02-18T22:02:54.000Z",
  "project_id": 6
  }
]

스코프: blobs#

이 스코프를 사용하여 코드를 검색합니다.

이 스코프에서는 다음 필터를 사용할 수 있습니다.

  • filename
  • path
  • extension

필터를 사용하려면 쿼리에 해당 필터를 포함합니다(예: a query filename:some_name*).

glob 매칭에는 와일드카드(*)를 사용할 수 있습니다.

blob 검색은 파일 이름과 콘텐츠 양쪽을 대상으로 수행됩니다. 검색 결과는 다음과 같습니다.

  • 파일 이름에서 찾은 결과가 콘텐츠에서 찾은 결과보다 먼저 표시됩니다.
  • 검색 문자열이 파일 이름과 콘텐츠 양쪽에서 발견되거나 콘텐츠 안에서 여러 번 나타날 수 있으므로, 같은 blob에 대한 일치 항목이 여러 개 포함될 수 있습니다.
curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/6/search?scope=blobs&search=keyword%20filename:*.py"

응답 예시:


[
  {
    "basename": "README",
    "data": "```\n\n## Installation\n\nQuick start using the [pre-built",
    "path": "README.md",
    "filename": "README.md",
    "id": null,
    "ref": "main",
    "startline": 46,
    "project_id": 6
  }
]
Note

filename은 path로 대체되어 더 이상 사용되지 않습니다. 둘 다 리포지터리 내 파일의 전체 경로를 반환하지만, 앞으로 filename은 전체 경로가 아닌 파일 이름만 나타낼 예정입니다. 자세한 내용은 이슈 34521을 참고합니다. Elasticsearch 구문은 정확한 코드 검색에서 제대로 동작하지 않을 수 있습니다. 정확한 코드 검색에서는 Elasticsearch 와일드카드 쿼리를 정규 표현식으로 대체합니다. 자세한 내용은 이슈 521686을 참고합니다.

스코프: notes#

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/6/search?scope=notes&search=maxime"

응답 예시:

[
  {
    "id": 191,
    "body": "Harum maxime consequuntur et et deleniti assumenda facilis.",
    "attachment": null,
    "author": {
      "id": 23,
      "name": "User 1",
      "username": "user1",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/111d68d06e2d317b5a59c2c6c5bad808?s=80&d=identicon",
      "web_url": "http://localhost:3000/user1"
    },
    "created_at": "2017-09-05T08:01:32.068Z",
    "updated_at": "2017-09-05T08:01:32.068Z",
    "system": false,
    "noteable_id": 22,
    "noteable_type": "Issue",
    "project_id": 6,
    "noteable_iid": 2
  }
]

시맨틱 검색#

히스토리
  • GitLab 18.11에서 semantic_code_search_rest_api라는 기능 플래그와 함께 도입되었습니다. 기본적으로 활성화됩니다.
  • GitLab 19.2에서 기능 플래그 semantic_code_search_rest_api가 제거되었습니다.

키워드 매칭이 아닌 의미를 기반으로 프로젝트에서 코드를 검색합니다.

GET /projects/:id/search/semantic
Attribute Type Required Description
id integer or string Yes 프로젝트의 ID 또는 URL 인코딩된 경로.
q string Yes 자연어 검색 쿼리.
directory_path string No 검색 범위를 한정할 디렉터리 경로.
knn integer No 벡터 검색 중 고려할 최근접 이웃의 수(1-100). 기본값은 64입니다.
limit integer No 반환할 최대 결과 수(1-100). 기본값은 20입니다.

요청 예시:

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/12/search/semantic?q=authentication%20middleware"

응답 예시:

응답은 코드 검색 결과의 배열입니다. 각 결과에는 다음 필드가 포함됩니다.

Field Type Description
path string 리포지터리 루트를 기준으로 한 파일 경로.
content string 일치한 파일의 코드 콘텐츠 스니펫.
score number 쿼리와 결과 간의 의미적 유사도 점수(0-1). 점수가 높을수록 더 잘 일치함을 나타냅니다.
language string 파일의 프로그래밍 언어.
start_line integer 일치한 코드 스니펫이 시작되는 줄 번호.
blob_id string 파일의 Git blob ID.
file_url string GitLab에서 파일을 볼 수 있는 URL.
[
  {
    "path": "app/services/auth/jwt_service.rb",
    "content": "def verify_token(token)\n  JWT.decode(token, secret_key)...",
    "score": 0.91,
    "language": "ruby",
    "start_line": 42,
    "blob_id": "a1b2c3d4e5f6...",
    "file_url": "https://gitlab.example.com/my-org/my-project/-/blob/main/app/services/auth/jwt_service.rb"
  }
]