Skip to content
代码片段 群组 项目
未验证 提交 11162282 编辑于 作者: Dmitry Gruzd's avatar Dmitry Gruzd 提交者: GitLab
浏览文件

Merge branch '457498-update-zoekt-syntax-documentation' into 'master'

Zoekt: Update syntax documentation

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/150320



Merged-by: default avatarDmitry Gruzd <dgruzd@gitlab.com>
Approved-by: default avatarAshraf Khamis <akhamis@gitlab.com>
Approved-by: default avatarTerri Chu <tchu@gitlab.com>
Reviewed-by: default avatarDmitry Gruzd <dgruzd@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -7,17 +7,18 @@ source: /doc/user/search/exact_code_search.md ...@@ -7,17 +7,18 @@ source: /doc/user/search/exact_code_search.md
# Search tips # Search tips
| Query | Description | | Query | Regular expression mode | Exact match mode |
| -------------------- |-------------------------------------------------------------------------------------- | | -------------------- | ----------------------------------------------------- | ------------------------------ |
| `foo` | Returns files that contain `foo` | | `"foo"` | `foo` | `"foo"` |
| `"class foo"` | Returns files that contain the exact string `class foo` | | `foo file:^doc/` | `foo` in directories that start with `/doc` | `foo` in directories that start with `/doc` |
| `class foo` | Returns files that contain both `class` and `foo` | | `"class foo"` | `class foo` | `"class foo"` |
| `foo or bar` | Returns files that contain either `foo` or `bar` | | `class foo` | `class` and `foo` | `class foo` |
| `class Foo` | Returns files that contain `class` (case insensitive) and `Foo` (case sensitive) | | `foo or bar` | `foo` or `bar` | `foo or bar` |
| `class Foo case:yes` | Returns files that contain `class` and `Foo` (both case sensitive) | | `class Foo` | `class` (case insensitive) and `Foo` (case sensitive) | `class Foo` (case insensitive) |
| `foo -bar` | Returns files that contain `foo` but not `bar` | | `class Foo case:yes` | `class` and `Foo` (both case sensitive) | `class Foo` (case sensitive) |
| `foo file:js` | Searches for `foo` in files with names that contain `js` | | `foo -bar` | `foo` but not `bar` | `foo -bar` |
| `foo -file:test` | Searches for `foo` in files with names that do not contain `test` | | `foo file:js` | `foo` in files with names that contain `js` | `foo` in files with names that contain `js` |
| `foo lang:ruby` | Searches for `foo` in Ruby source code | | `foo -file:test` | `foo` in files with names that do not contain `test` | `foo` in files with names that do not contain `test` |
| `foo f:\.js$` | Searches for `foo` in files with names that end with `.js` | | `foo lang:ruby` | `foo` in Ruby source code | `foo` in Ruby source code |
| `foo.*bar` | Searches for strings that match the regular expression `foo.*bar` | | `foo file:\.js$` | `foo` in files with names that end with `.js` | `foo` in files with names that end with `.js` |
| `foo.*bar` | `foo.*bar` (regular expression) | None |
...@@ -60,22 +60,37 @@ Use this feature to search code across the entire GitLab instance. ...@@ -60,22 +60,37 @@ Use this feature to search code across the entire GitLab instance.
Global code search does not perform well on large GitLab instances. Global code search does not perform well on large GitLab instances.
If you enable this feature for instances with more than 20,000 projects, your search might time out. If you enable this feature for instances with more than 20,000 projects, your search might time out.
## Syntax ## Search modes
This table shows some example queries for exact code search. > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/434417) in GitLab 16.8 [with a flag](../../administration/feature_flags.md) named `zoekt_exact_search`. Disabled by default.
| Query | Description | FLAG:
|----------------------|-----------------------------------------------------------------------------------| The availability of this feature is controlled by a feature flag.
| `foo` | Returns files that contain `foo`. | For more information, see the history.
| `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`. | When you enable `zoekt_exact_search`, you can switch between two search modes:
| `class foo` | Returns files that contain both `class` and `foo`. |
| `foo or bar` | Returns files that contain either `foo` or `bar`. | - **Regular expression mode:** supports regular and boolean expressions.
| `class Foo` | Returns files that contain `class` (case insensitive) and `Foo` (case sensitive). | - **Exact match mode:** returns results that exactly match the query.
| `class Foo case:yes` | Returns files that contain `class` and `Foo` (both case sensitive). |
| `foo -bar` | Returns files that contain `foo` but not `bar`. | When `zoekt_exact_search` is disabled, the regular expression mode is used by default.
| `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`. | ### Syntax
| `foo lang:ruby` | Searches for `foo` in Ruby source code. |
| `foo file:\.js$` | Searches for `foo` in files with names that end with `.js`. | This table shows some example queries for regular expression and exact match modes.
| `foo.*bar` | Searches for strings that match the regular expression `foo.*bar`. |
| Query | Regular expression mode | Exact match mode |
| -------------------- | ----------------------------------------------------- | ------------------------------ |
| `"foo"` | `foo` | `"foo"` |
| `foo file:^doc/` | `foo` in directories that start with `/doc` | `foo` in directories that start with `/doc` |
| `"class foo"` | `class foo` | `"class foo"` |
| `class foo` | `class` and `foo` | `class foo` |
| `foo or bar` | `foo` or `bar` | `foo or bar` |
| `class Foo` | `class` (case insensitive) and `Foo` (case sensitive) | `class Foo` (case insensitive) |
| `class Foo case:yes` | `class` and `Foo` (both case sensitive) | `class Foo` (case sensitive) |
| `foo -bar` | `foo` but not `bar` | `foo -bar` |
| `foo file:js` | `foo` in files with names that contain `js` | `foo` in files with names that contain `js` |
| `foo -file:test` | `foo` in files with names that do not contain `test` | `foo` in files with names that do not contain `test` |
| `foo lang:ruby` | `foo` in Ruby source code | `foo` in Ruby source code |
| `foo file:\.js$` | `foo` in files with names that end with `.js` | `foo` in files with names that end with `.js` |
| `foo.*bar` | `foo.*bar` (regular expression) | None |
--- ---
name: zoekt_exact_search name: zoekt_exact_search
feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/389745 feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/434417
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/140346 introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/140346
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/436457 rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/436457
milestone: '16.8' milestone: '16.8'
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册