Searching in GitLab
- Tier: Free, Premium, Ultimate
- Offering: GitLab.com, Self-managed, GitLab Dedicated
GitLab has three types of search: basic search, advanced search, and exact code search.
For code search, GitLab uses these types in this order:
- Exact code search: where you can use exact match and regular expression modes.
- Advanced search: when exact code search is not available.
- Basic search: when exact code search and advanced search are not available or when you search against a non-default branch. This type does not support group or global search.
Specify a search type
To specify a search type, set the search_type
URL parameter as follows:
search_type=zoekt
for exact code searchsearch_type=advanced
for advanced searchsearch_type=basic
for basic search
search_type
replaces the deprecated basic_search
parameter.
For more information, see issue 477333.
Restrict search access
- Offering: Self-managed
Prerequisites:
- You must have administrator access to the instance.
By default, requests to /search
and global search are available for unauthenticated users.
To restrict /search
to authenticated users only, do one of the following:
- Restrict public visibility (introduced in GitLab 17.6).
- Disable the
ops
feature flagallow_anonymous_searches
(introduced in GitLab 16.7).
To restrict global search to authenticated users only,
enable the ops
feature flag block_anonymous_global_searches
.
Global search scopes
- Tier: Free, Premium, Ultimate
- Offering: Self-managed
To improve the performance of your instance’s global search, an administrator can limit the search scope
by disabling one or more ops
feature flags.
Scope | Feature flag | Description |
---|---|---|
Code | global_search_code_tab |
When enabled, global search includes code. |
Commits | global_search_commits_tab |
When enabled, global search includes commits. |
Epics | global_search_epics_tab |
When enabled, global search includes epics. |
Issues | global_search_issues_tab |
When enabled, global search includes issues. |
Merge requests | global_search_merge_requests_tab |
When enabled, global search includes merge requests. |
Users | global_search_users_tab |
When enabled, global search and command palette includes users. |
Wiki | global_search_wiki_tab |
When enabled, global search includes project and group wikis. |
All global search scopes are enabled by default on self-managed instances.
Global search validation
Global search ignores and logs as abusive any search that includes:
- Fewer than two characters
- A term longer than 100 characters (URL search terms must not exceed 200 characters)
- A stop word only (for example,
the
,and
, orif
) - An unknown
scope
group_id
orproject_id
that is not completely numericrepository_ref
orproject_ref
with special characters not allowed by Git refname
Global search only flags with an error any search that includes more than:
- 4096 characters
- 64 terms
Partial matches are not supported in issue search.
For example, when you search issues for play
, the query does not return issues that contain display
.
However, the query matches all possible variations of the string (for example, plays
).
Autocomplete suggestions
As you type in the search box, autocomplete suggestions are displayed for:
- Projects and groups
- Users
- Help pages
- Project features (for example, milestones)
- Settings (for example, user settings)
- Recently viewed merge requests
- Recently viewed issues and epics
- GitLab Flavored Markdown references for issues in a project
Search in all GitLab
To search in all GitLab:
- On the left sidebar, at the top, select Search or go to.
- Type your search query. You must type at least two characters.
- Press Enter to search, or select from the list.
The results are displayed. To filter the results, on the left sidebar, select a filter.
Search in a project
To search in a project:
- On the left sidebar, select Search or go to and find your project.
- Select Search or go to again and type the string you want to search for.
- Press Enter to search, or select from the list.
The results are displayed. To filter the results, on the left sidebar, select a filter.
Search for a project by full path
You can search for a project by entering its full path (including the namespace it belongs to) in the search box. As you type the project path, autocomplete suggestions are displayed.
For example:
gitlab-org/gitlab
searches for thegitlab
project in thegitlab-org
namespace.gitlab-org/
displays autocomplete suggestions for projects that belong to thegitlab-org
namespace.
Include archived projects in search results
By default, archived projects are excluded from search results. To include archived projects in search results:
- On the search page, on the left sidebar, select the Include archived checkbox.
- On the left sidebar, select Apply.
Search for code
To search for code in a project:
- On the left sidebar, select Search or go to and find your project.
- Select Search or go to again and type the code you want to search for.
- Press Enter to search, or select from the list.
Code search shows only the first result in the file. To search for code in all GitLab, ask your administrator to enable advanced search.
View Git blame from code search
After you find search results, you can view who made the last change to the line where the results were found.
- From the code search result, hover over the line number.
- On the left, select View blame.
Filter code search results by language
To filter code search results by one or more languages:
- On the code search page, on the left sidebar, select one or more languages.
- On the left sidebar, select Apply.
Search for a commit SHA
To search for a commit SHA:
- On the left sidebar, select Search or go to and find your project.
- Select Search or go to again and type the commit SHA you want to search for.
- Press Enter to search, or select from the list.
If a single result is returned, GitLab redirects to the commit result and gives you the option to return to the search results page.
Docs
Edit this page to fix an error or add an improvement in a merge request.
Create an issue to suggest an improvement to this page.
Product
Create an issue if there's something you don't like about this feature.
Propose functionality by submitting a feature request.
Feature availability and product trials
View pricing to see all GitLab tiers and features, or to upgrade.
Try GitLab for free with access to all features for 30 days.
Get help
If you didn't find what you were looking for, search the docs.
If you want help with something specific and could use community support, post on the GitLab forum.
For problems setting up or using this feature (depending on your GitLab subscription).
Request support