doc/user/search/_index.md
{{< details >}}
{{< /details >}}
Find what you need in a growing codebase or expanding organization. Save time by looking up specific code, work items, merge requests, and other content across your projects. Choose from three types of search to match your needs: basic search, advanced search, and exact code search.
For code search, GitLab uses these types in this order:
Scopes describe the type of data you're searching. The following scopes are available for basic search:
| Scope | Global <sup>1</sup> | Group | Project |
|---|---|---|---|
| Code | {{< no >}} | {{< no >}} | {{< yes >}} |
| Comments | {{< no >}} | {{< no >}} | {{< yes >}} |
| Commits | {{< no >}} | {{< no >}} | {{< yes >}} |
| Work items | {{< yes >}} | {{< yes >}} | {{< yes >}} |
| Merge requests | {{< yes >}} | {{< yes >}} | {{< yes >}} |
| Milestones <sup>2</sup> | {{< yes >}} | {{< yes >}} | {{< yes >}} |
| Projects | {{< yes >}} | {{< yes >}} | {{< no >}} |
| Users | {{< yes >}} | {{< yes >}} | {{< yes >}} |
| Wikis | {{< no >}} | {{< no >}} | {{< yes >}} |
Footnotes:
{{< history >}}
{{< /history >}}
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 searchsearch_type replaces the deprecated basic_search parameter.
For more information, see issue 477333.
{{< details >}}
{{< /details >}}
{{< history >}}
block_anonymous_global_searches. Disabled by default.allow_anonymous_searches. Enabled by default.block_anonymous_global_searches removed.allow_anonymous_searches removed.{{< /history >}}
Prerequisites:
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 visibility levels for the project or group. If public projects are restricted, anonymous global search is redirected to the GitLab sign-in page.
Restrict access in the Admin area:
To restrict global search to authenticated users only:
{{< details >}}
{{< /details >}}
{{< history >}}
{{< /history >}}
Prerequisites:
To improve the performance of your instance's global search, you can disable one or more search scopes. All global search scopes are enabled by default on GitLab Self-Managed instances.
To disable one or more global search scopes:
{{< details >}}
{{< /details >}}
Prerequisites:
By default, when users do not select a search scope, a scope is selected automatically based on context and availability. To configure a default search scope instead:
Users can override the default scope by selecting another scope. If the default scope is not available (for example, code in global search), a scope is selected automatically.
{{< history >}}
issues_full_text_search. Disabled by default.issues_full_text_search removed.{{< /history >}}
Global search ignores and logs as abusive any search that includes:
the, and, or if)scopegroup_id or project_id that is not completely numericrepository_ref or project_ref with special characters not allowed by Git refnameGlobal search only flags with an error any search that includes more than:
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).
{{< history >}}
users_search_scoped_to_authorized_namespaces_advanced_search, users_search_scoped_to_authorized_namespaces_basic_search, and users_search_scoped_to_authorized_namespaces_basic_search_by_ids. Disabled by default.users_search_scoped_to_authorized_namespaces_advanced_search, users_search_scoped_to_authorized_namespaces_basic_search, and users_search_scoped_to_authorized_namespaces_basic_search_by_ids removed.{{< /history >}}
[!flag] The availability of this feature is controlled by feature flags. For more information, see the history.
As you type in the search box, autocomplete suggestions are displayed for:
To search in all GitLab:
The results are displayed. To filter the results, in the left sidebar, select a filter.
To search in a project:
The results are displayed. To filter the results, in the left sidebar, select a filter.
{{< history >}}
search_projects_hide_archived for project search. Disabled by default.{{< /history >}}
By default, archived projects are excluded from search results. To include archived projects in search results:
To search for code in a project:
Code search shows only the first result in the file. To search for code in all GitLab, ask your administrator to enable advanced search.
{{< history >}}
{{< /history >}}
After you find search results, you can view who made the last change to the line where the results were found.
{{< history >}}
{{< /history >}}
To filter code search results by one or more languages:
To search for a commit SHA:
If a single result is returned, GitLab redirects to the commit result and gives you the option to return to the search results page.
Basic search uses exact substring matching with the following options:
| Syntax | Description | Example |
|---|---|---|
filename: | Filename | filename:*spec.rb |
path: | Repository location (full or partial matches) | path:spec/workers/ |
extension: | File extension without . (exact matches only) | extension:js |
| Query | Description |
|---|---|
rails -filename:gemfile.lock | Returns rails in all files except the gemfile.lock file. |
helper -extension:yml -extension:js | Returns helper in all files except files with a .yml or .js extension. |
helper path:lib/git | Returns helper in all files with a lib/git* path (for example, spec/lib/gitlab). |