debian-mirror-gitlab/doc/user/search/advanced_search.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

100 lines
7.5 KiB
Markdown
Raw Normal View History

2020-10-24 23:57:45 +05:30
---
2022-07-23 23:45:48 +05:30
stage: Data Stores
2021-01-03 14:25:43 +05:30
group: Global Search
2022-11-25 23:54:43 +05:30
info: "To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments"
2020-10-24 23:57:45 +05:30
type: reference
---
2023-05-27 22:25:52 +05:30
# Advanced search **(PREMIUM)**
2019-07-31 22:56:46 +05:30
2022-05-07 20:08:51 +05:30
> Moved to GitLab Premium in 13.9.
2019-07-31 22:56:46 +05:30
2023-05-27 22:25:52 +05:30
You can use advanced search for faster, more efficient search across the entire GitLab
instance. Advanced search is based on Elasticsearch, a purpose-built full-text search
2022-10-11 01:57:18 +05:30
engine you can horizontally scale to get results in up to a second in most cases.
2020-05-24 23:13:21 +05:30
2022-10-11 01:57:18 +05:30
You can find code you want to update in all projects at once to save
maintenance time and promote innersourcing.
2023-05-27 22:25:52 +05:30
You can use advanced search in:
2021-04-17 20:07:23 +05:30
- Projects
- Issues
- Merge requests
- Milestones
2022-07-23 23:45:48 +05:30
- Users
2022-10-11 01:57:18 +05:30
- Epics (in groups only)
2021-04-17 20:07:23 +05:30
- Code
2022-07-23 23:45:48 +05:30
- Comments
2021-04-17 20:07:23 +05:30
- Commits
2022-10-11 01:57:18 +05:30
- Project wikis (not [group wikis](../project/wiki/group.md))
2022-07-23 23:45:48 +05:30
2023-05-27 22:25:52 +05:30
## Enable advanced search
2023-03-04 22:38:38 +05:30
2023-05-27 22:25:52 +05:30
- On GitLab.com, advanced search is enabled for groups with paid subscriptions.
2022-10-11 01:57:18 +05:30
- For self-managed GitLab instances, an administrator must
2023-05-27 22:25:52 +05:30
[enable advanced search](../../integration/advanced_search/elasticsearch.md#enable-advanced-search).
2020-10-24 23:57:45 +05:30
2022-10-11 01:57:18 +05:30
## Syntax
2021-02-22 17:27:13 +05:30
2023-05-27 22:25:52 +05:30
Advanced search uses [Elasticsearch syntax](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html#simple-query-string-syntax). The syntax supports both exact and fuzzy search queries.
2021-02-22 17:27:13 +05:30
2023-01-13 00:05:48 +05:30
<!-- markdownlint-disable -->
2021-02-22 17:27:13 +05:30
2023-01-13 00:05:48 +05:30
| Syntax | Description | Example |
|--------------|---------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| `"` | Exact search | [`"gem sidekiq"`](https://gitlab.com/search?group_id=9970&project_id=278964&scope=blobs&search=%22gem+sidekiq%22) |
2023-05-27 22:25:52 +05:30
| `~` | Fuzzy search | [`J~ Doe`](https://gitlab.com/search?scope=users&search=j%7E+doe) |
2023-01-13 00:05:48 +05:30
| <code>&#124;</code> | Or | [<code>display &#124; banner</code>](https://gitlab.com/search?group_id=9970&project_id=278964&scope=blobs&search=display+%7C+banner) |
| `+` | And | [`display +banner`](https://gitlab.com/search?group_id=9970&project_id=278964&repository_ref=&scope=blobs&search=display+%2Bbanner&snippets=) |
| `-` | Exclude | [`display -banner`](https://gitlab.com/search?group_id=9970&project_id=278964&scope=blobs&search=display+-banner) |
| `*` | Partial | [`bug error 50*`](https://gitlab.com/search?group_id=9970&project_id=278964&repository_ref=&scope=blobs&search=bug+error+50%2A&snippets=) |
| `\` | Escape | [`\*md`](https://gitlab.com/search?snippets=&scope=blobs&repository_ref=&search=%5C*md&group_id=9970&project_id=278964) |
| `#` | Issue ID | [`#23456`](https://gitlab.com/search?snippets=&scope=issues&repository_ref=&search=%2323456&group_id=9970&project_id=278964) |
| `!` | Merge request ID | [`!23456`](https://gitlab.com/search?snippets=&scope=merge_requests&repository_ref=&search=%2123456&group_id=9970&project_id=278964) |
2023-05-27 22:25:52 +05:30
### Refining user search
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/388409) in GitLab 15.10.
In user search, a [fuzzy query](https://www.elastic.co/guide/en/elasticsearch/reference/7.2/query-dsl-fuzzy-query.html) is used by default. You can refine your search with [Elasticsearch syntax](#syntax).
2023-01-13 00:05:48 +05:30
### Code search
| Syntax | Description | Example |
|--------------|---------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| `filename:` | Filename | [`filename:*spec.rb`](https://gitlab.com/search?snippets=&scope=blobs&repository_ref=&search=filename%3A*spec.rb&group_id=9970&project_id=278964) |
2023-05-27 22:25:52 +05:30
| `path:` | Repository location <sup>1</sup> | [`path:spec/workers/`](https://gitlab.com/search?group_id=9970&project_id=278964&repository_ref=&scope=blobs&search=path%3Aspec%2Fworkers&snippets=) |
| `extension:` | File extension without `.` <sup>2</sup> | [`extension:js`](https://gitlab.com/search?group_id=9970&project_id=278964&repository_ref=&scope=blobs&search=extension%3Ajs&snippets=) |
| `blob:` | Git object ID <sup>2</sup> | [`blob:998707*`](https://gitlab.com/search?snippets=false&scope=blobs&repository_ref=&search=blob%3A998707*&group_id=9970) |
2023-01-13 00:05:48 +05:30
2023-05-27 22:25:52 +05:30
1. `path:` returns matches for full paths or subpaths.
1. `extension:` and `blob:` return exact matches only.
2023-01-13 00:05:48 +05:30
### Examples
| Query | Description |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------|
| [`rails -filename:gemfile.lock`](https://gitlab.com/search?group_id=9970&project_id=278964&repository_ref=&scope=blobs&search=rails+-filename%3Agemfile.lock&snippets=) | Returns `rails` in all files except the `gemfile.lock` file. |
| [`RSpec.describe Resolvers -*builder`](https://gitlab.com/search?group_id=9970&project_id=278964&scope=blobs&search=RSpec.describe+Resolvers+-*builder) | Returns `RSpec.describe Resolvers` that does not start with `builder`. |
| [<code>bug &#124; (display +banner)</code>](https://gitlab.com/search?snippets=&scope=issues&repository_ref=&search=bug+%7C+%28display+%2Bbanner%29&group_id=9970&project_id=278964) | Returns `bug` or both `display` and `banner`. |
| [<code>helper -extension:yml -extension:js</code>](https://gitlab.com/search?group_id=9970&project_id=278964&repository_ref=&scope=blobs&search=helper+-extension%3Ayml+-extension%3Ajs&snippets=) | Returns `helper` in all files except files with a `.yml` or `.js` extension. |
2023-05-27 22:25:52 +05:30
| [<code>helper path:lib/git</code>](https://gitlab.com/search?group_id=9970&project_id=278964&scope=blobs&search=helper+path%3Alib%2Fgit) | Returns `helper` in all files with a `lib/git*` path (for example, `spec/lib/gitlab`). |
2023-01-13 00:05:48 +05:30
<!-- markdownlint-enable -->
2023-05-27 22:25:52 +05:30
## Known issues
- You can only search files smaller than 1 MB.
For self-managed GitLab instances, an administrator can
[change this limit](../../integration/advanced_search/elasticsearch.md#advanced-search-configuration).
- You can only use advanced search on the default branch of a project.
- The search query must not contain any of the following characters:
```plaintext
. , : ; / ` ' = ? $ & ^ | < > ( ) { } [ ] @
```
- Search results show only the first match in a file.