GitLab Advanced Search (PREMIUM)
- Moved to GitLab Premium in 13.9.
NOTE: This is the user documentation. To configure the Advanced Search, visit the administrator documentation. Advanced Search is enabled in GitLab.com.
GitLab Advanced Search expands on the Basic Search with an additional set of features for faster, more advanced searches across the entire GitLab instance when searching in:
- Projects
- Issues
- Merge requests
- Milestones
- Epics
- Comments
- Code
- Commits
- Wiki (except group wikis)
- Users
The Advanced Search can be useful in various scenarios:
- Faster searches: Advanced Search is based on Elasticsearch, which is a purpose-built full text search engine that can be horizontally scaled so that it can provide search results in 1-2 seconds in most cases.
- Code Maintenance: Finding all the code that needs to be updated at once across an entire instance can save time spent maintaining code. This is especially helpful for organizations with more than 10 active projects. This can also help build confidence is code refactoring to identify unknown impacts.
- Promote innersourcing: Your company may consist of many different developer teams each of which has their own group where the various projects are hosted. Some of your applications may be connected to each other, so your developers need to instantly search throughout the GitLab instance and find the code they search for.
Use the Advanced Search syntax
Elasticsearch has data for the default branch only. That means that if you go to the repository tree and switch the branch from the default to something else, then the Code tab in the search result page is served by the basic search even if Elasticsearch is enabled.
The Advanced Search syntax supports fuzzy or exact search queries with prefixes, boolean operators, and much more. Use the search as before and GitLab shows you matching code from each project you have access to.
Full details can be found in the Elasticsearch documentation, but here's a quick guide:
- Searches look for all the words in a query, in any order - for example: searching
issues for
display bug
andbug display
return the same results. - To find the exact phrase (stemming still applies), use double quotes:
"display bug"
- To find bugs not mentioning display, use
-
:bug -display
- To find a bug in display or banner, use
|
:bug display | banner
- To group terms together, use parentheses:
bug | (display +banner)
- To match a partial word, use
*
. In this example, I want to find bugs with any 500 errors. :bug error 50*
- To use one of symbols above literally, escape the symbol with a preceding
\
:argument \-last
Syntax search filters
Advanced Search also supports the use of filters. The available filters are:
-
filename
: Filters by filename. You can use the glob (*
) operator for fuzzy matching. -
path
: Filters by path. You can use the glob (*
) operator for fuzzy matching. -
extension
: Filters by extension in the filename. Please write the extension without a leading dot. Exact match only. -
blob
: Filters by Gitobject ID
. Exact match only.
To use them, add them to your keyword in the format <filter_name>:<value>
without
any spaces between the colon (:
) and the value. When no keyword is provided, an asterisk (*
) is used as the keyword.
Examples:
- Finding a file with any content named
search_results.rb
:* filename:search_results.rb
- The leading asterisk (
*
) can be ignored in the case above:filename:search_results.rb
- Finding a file named
found_blob_spec.rb
with the textCHANGELOG
inside of it:CHANGELOG filename:found_blob_spec.rb
- Finding the text
EpicLinks
inside files with the.rb
extension:EpicLinks extension:rb
- Finding any file with the
.yaml
extension:extension:yaml
- Finding the text
Sidekiq
in a file, when that file is in a path that includeselastic
:Sidekiq path:elastic
- Finding any file in a path that includes
elasticsearch
:path:elasticsearch
- Finding the files represented by the Git object ID
998707b421c89bd9a3063333f9f728ef3e43d101
:* blob:998707b421c89bd9a3063333f9f728ef3e43d101
- Syntax filters can be combined for complex filtering. Finding any file starting with
search
containingeventHub
and with the.js
extension:eventHub filename:search* extension:js
Excluding filters
Introduced in GitLab 13.3.
Filters can be inverted to filter out results from the result set, by prefixing the filter name with a -
(hyphen) character, such as:
-filename
-path
-extension
-blob
Examples:
- Finding
rails
in all files butGemfile.lock
:rails -filename:Gemfile.lock
- Finding
success
in all files excluding.po|pot
files:success -filename:*.po*
- Finding
import
excluding minified JavaScript (.min.js
) files:import -extension:min.js
- Finding
docs
for all files outside thedocs/
folder:docs -path:docs/
Search by issue or merge request ID
You can search a specific issue or merge request by its ID with a special prefix.
- To search by issue ID, use prefix
#
followed by issue ID. For example, #23456 - To search by merge request ID, use prefix
!
followed by merge request ID. For example !23456
Global search scopes (FREE SELF)
Introduced in GitLab 14.3.
To improve the performance of your instance's global search, you can limit
the scope of the search. To do so, you can exclude global search scopes by disabling
ops
feature flags.
Global search has all its scopes enabled by default in GitLab SaaS and
self-managed instances. A GitLab administrator can disable the following ops
feature flags to limit the scope of your instance's global search and optimize
its performance:
Scope | Feature flag | Description |
---|---|---|
Code | global_search_code_tab |
When enabled, the global search includes code as part of the search. |
Commits | global_search_commits_tab |
When enabled, the global search includes commits as part of the search. |
Issues | global_search_issues_tab |
When enabled, the global search includes issues as part of the search. |
Merge Requests | global_search_merge_requests_tab |
When enabled, the global search includes merge requests as part of the search. |
Wiki | global_search_wiki_tab |
When enabled, the global search includes wiki as part of the search. Group wikis are not included. |