Back to Gitlabhq

Advanced search

doc/user/search/advanced_search.md

18.11.27.0 KB
Original Source

{{< details >}}

  • Tier: Premium, Ultimate
  • Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated

{{< /details >}}

Use advanced search to find exactly what you need across your entire GitLab instance.

With advanced search:

  • Identify code patterns across all projects to refactor shared components more efficiently.
  • Locate security vulnerabilities across your entire organization's codebase and dependencies.
  • Track usage of deprecated functions or libraries throughout all repositories.
  • Find discussions buried in issues, merge requests, or comments.
  • Discover existing solutions instead of reinventing functionality that already exists.

Advanced search works in:

  • Code
  • Comments
  • Commits
  • Work items
  • Merge requests
  • Milestones
  • Projects
  • Users
  • Wikis

Prerequisites:

  • Advanced search must be enabled:
    • For GitLab.com and GitLab Dedicated, advanced search is enabled by default in paid subscriptions.
    • For GitLab Self-Managed, an administrator must enable advanced search.

To use advanced search:

  1. In the top bar, select Search or go to.
  2. In the search box, enter your search term.

You can also use advanced search in a project or group.

Available scopes

{{< history >}}

  • Searching comments on issues introduced in GitLab 18.0 with a flag named search_work_item_queries_notes. Disabled by default.
  • Searching comments on issues enabled on GitLab.com in GitLab 18.1.
  • Searching comments on issues generally available in GitLab 18.6. Feature flag search_work_item_queries_notes removed.
  • Searching comments on merge requests introduced in GitLab 18.6 with a flag named search_merge_request_queries_notes. Disabled by default.
  • Searching comments on merge requests generally available in GitLab 18.7. Feature flag search_merge_request_queries_notes removed.

{{< /history >}}

Scopes describe the type of data you're searching. The following scopes are available for advanced search:

ScopeGlobal <sup>1</sup> <sup>2</sup>GroupProject
Code{{< yes >}}{{< yes >}}{{< yes >}}
Comments{{< yes >}}{{< yes >}}{{< yes >}}
Commits{{< yes >}}{{< yes >}}{{< yes >}}
Work items <sup>3</sup>{{< yes >}}{{< yes >}}{{< yes >}}
Merge requests <sup>3</sup>{{< yes >}}{{< yes >}}{{< yes >}}
Milestones <sup>4</sup>{{< yes >}}{{< yes >}}{{< yes >}}
Projects{{< yes >}}{{< yes >}}{{< no >}}
Users{{< yes >}}{{< yes >}}{{< yes >}}
Wikis{{< yes >}}{{< yes >}}{{< yes >}}

Footnotes:

  1. An administrator can disable global search scopes. On GitLab Self-Managed, global search is not available when limited indexing is enabled by default. An administrator can enable global search for limited indexing.
  2. On GitLab.com, global search is not enabled for code, commits, and wikis.
  3. When you search work items and merge requests, results include comments that match your search term.
  4. Advanced search returns only project milestones because group milestones are not indexed in Elasticsearch. For more information, see issue 428589.

Syntax

<!-- Remember to also update the tables in `doc/drawers/advanced_search_syntax.md` -->

Advanced search uses simple_query_string, which supports both exact and fuzzy queries.

When you search for a user, the fuzzy query is used by default. You can refine user search with simple_query_string.

SyntaxDescriptionExample
"Exact search"gem sidekiq"
~Fuzzy searchJ~ Doe
|Ordisplay | banner
+Anddisplay +banner
-Excludedisplay -banner
*Partialbug error 50*
\Escape\*md
#Issue ID#23456
!Merge request ID!23456
SyntaxDescriptionExample
filename:Filenamefilename:*spec.rb
path:Repository location (full or partial matches)path:spec/workers/
extension:File extension without . (exact matches only)extension:js
blob:Git object ID (exact matches only)blob:998707*

Examples

QueryDescription
rails -filename:gemfile.lockReturns rails in all files except the gemfile.lock file.
RSpec.describe Resolvers -*builderReturns RSpec.describe Resolvers that does not start with builder.
bug | (display +banner)Returns bug or both display and banner.
helper -extension:yml -extension:jsReturns helper in all files except files with a .yml or .js extension.
helper path:lib/gitReturns helper in all files with a lib/git* path (for example, spec/lib/gitlab).

Known issues

  • You can search only files smaller than 1 MB. For GitLab Self-Managed, an administrator can set a limit on the maximum file size indexed.

  • You can use advanced search only on the default branch of a project. For more information, see issue 229966.

  • The search query must not contain any of the following characters:

    plaintext
    . , : ; / ` ' = ? $ & ^ | < > ( ) { } [ ] @
    
  • Search results show only the first match in a file.