0
0
Fork 0
mirror of https://codeberg.org/forgejo/docs.git synced 2025-01-14 01:18:59 -05:00

user/code-search: Update code search (#967)

Reviewed-on: https://codeberg.org/forgejo/docs/pulls/967
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: snematoda <snematoda.751k2@aleeas.com>
Co-committed-by: snematoda <snematoda.751k2@aleeas.com>
This commit is contained in:
snematoda 2024-12-18 07:42:01 +00:00 committed by Earl Warren
parent 13a2d0ba70
commit 6d572a0d79

View file

@ -9,18 +9,35 @@ Forgejo supports code search through an indexer and `git-grep` as a fallback whe
![Code search results page using git-grep](../_images/user/code-search/gitgrep.png)
If `REPO_INDEXER_ENABLED` is set to `false`, the code search function will be limited to a single repository and will use [`git-grep`](https://git-scm.com/docs/git-grep).
When `REPO_INDEXER_ENABLED` is set to `false`, code search is restricted to a single repository, utilizing the [`git-grep`](https://git-scm.com/docs/git-grep) command.
Currently, only fixed strings are supported and any case differences are ignored. The search results will include the matched line, along with a single line before and after the match.
## Supported Options
Since, the searches are performed on the fly they may be performed on any valid branch or tag.
The following options are currently available for code search while using `git-grep`.
The active branch/tag will be displayed as the default value on the dropdown present just above the search bar, which may also be used to easily switch between branches and tags.
- **Match**: Perform an exact match on the provided expression.
- **Union**: Conduct a union match, returning results that contain atleast one of the specified keywords. For example, a search query containing `hello world` will yeild results with either `hello` or `world`.
- **RegExp**: Utilize the provided regular expression to perform a pettern-based match (matches will not be highlighted).
## Scope
Since `git-grep` is performed on the fly, they can be executed on any valid branch or tag. The currently active branch/tag is displayed as the default value in the dropdown menu above the search bar, allowing users to easily switch between branches and tags.
# Indexer
![Code search results page using indexer](../_images/user/code-search/indexer.png)
For advanced search queries and searching across an entire organisation or instance, `REPO_INDEXER_ENABLED: true` enables code search via bleve/elasticsearch.
For complex searches or cross-repository queries across an entire organisation or instance, `REPO_INDEXER_ENABLED` must be set to `true`. This enables code search via the selected indexer ([`REPO_INDEXER_TYPE`](../../admin/config-cheat-sheet#indexer-indexer)).
However, search results are limited to the HEAD of the repository.
## Supported Options
The following options are currently available for code search while using an indexer.
- **Match**: Perform an exact match on the provided expression.
- **Fuzzy**: Conduct a fuzzy search, returning results that contain the keyword within a maximum edit-distance of 2. For example, a search query containing `hello` will yeild results with
- **edit distance of 0**: `hello`
- **edit distance of 1**: For example, `hllo` (delete), `helloo` (add), `hallo` (modify).
## Scope
Please note that when using the repository indexer, search results are limited to the contents of the HEAD branch of each repository.