Exact Code Search
DETAILS: Tier: Premium, Ultimate Offering: SaaS, self-managed Status: Beta
- Introduced in GitLab 15.9 with flags named
index_code_with_zoekt
andsearch_code_with_zoekt
. Disabled by default.
FLAG:
On self-managed GitLab, by default this feature is not available.
To make it available, an administrator can enable the feature flags named index_code_with_zoekt
and search_code_with_zoekt
.
On GitLab.com, this feature is available. The feature is not ready for production use.
WARNING: This feature is in Beta and subject to change without notice. For more information, see epic 9404.
Usage
When performing any Code search in GitLab it will choose to use "Exact Code Search" powered by Zoekt if the project is part of an enabled Group.
The main differences between Zoekt and advanced search are that Zoekt provides exact substring matching as well as allows you to search for regular expressions. Since it allows searching for regular expressions, certain special characters will require escaping. Backslash can escape special characters and wrapping in double quotes can be used for phrase searches.
Zoekt search API
- Introduced in GitLab 16.9 with a flag named
zoekt_search_api
. Enabled by default.
FLAG:
On self-managed GitLab, by default this feature is available.
To hide the feature, an administrator can disable the feature flag named zoekt_search_api
.
On GitLab.com, this feature is not available. The feature is not ready for production use.
By default, the Zoekt search API is disabled on GitLab.com to avoid breaking changes.
To request access to this feature, contact GitLab.
Syntax
This table shows some example queries for exact code search.
Query | Description |
---|---|
foo |
Returns files that contain foo
|
foo file:^doc/ |
Returns files that contain foo in directories that start with doc/
|
"class foo" |
Returns files that contain the exact string class foo
|
class foo |
Returns files that contain both class and foo
|
foo or bar |
Returns files that contain either foo or bar
|
class Foo |
Returns files that contain class (case insensitive) and Foo (case sensitive) |
class Foo case:yes |
Returns files that contain class and Foo (both case sensitive) |
foo -bar |
Returns files that contain foo but not bar
|
foo file:js |
Searches for foo in files with names that contain js
|
foo -file:test |
Searches for foo in files with names that do not contain test
|
foo lang:ruby |
Searches for foo in Ruby source code |
foo file:\.js$ |
Searches for foo in files with names that end with .js
|
foo.*bar |
Searches for strings that match the regular expression foo.*bar
|