Search
Code Search
Forgejo supports code search through an indexer and git-grep as a fallback when REPO_INDEXER_ENABLED is disabled.
Basic (git-grep)
When REPO_INDEXER_ENABLED is set to false, code search is restricted to a single repository, utilizing the git-grep command.
Supported Options
The following options are currently available for code search while using git-grep.
- Exact: Perform an exact match on the provided expression.
- Union: Conduct a union match, returning results that contain at least one of the specified keywords. For example, a search query containing
hello worldwill yield results with eitherhelloorworld. - RegExp: Utilize the provided regular expression to perform a pattern-based match (matches will not be highlighted).
Scope
Since git-grep is performed on the fly, it 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.
Searching within a specific directory (or file) executes git-grep using a literal pathspec for the given path. If REPO_INDEXER_INCLUDE has been set by the administrator, the filter is added if and only if it matches one of the globs.
Example
Performing a search for foo at /{user}/{repo}/src/branch/main?path=src returns results that belong to the branch main inside the directory /src.
main
├── docs -> [...]
└── src
└── main.go
└── utils.go
In the above figure, the search would match results for foo in main.go and utils.go, but not from docs/*.
Indexer
For complex searches or cross-repository queries across an entire organization or instance, REPO_INDEXER_ENABLED must be set to true.
This enables code search via the selected indexer (REPO_INDEXER_TYPE).
Supported Options
The following options are currently available for code search while using an indexer.
- Exact: Perform an exact match on the provided expression.
- Union: Conduct a union match, returning results that contain at least one of the specified keywords. For example, a search query containing
hello worldwill yield results with eitherhelloorworld. - Fuzzy (if enabled by the administrator): Conduct a fuzzy search, returning results that contain the keyword within a maximum edit distance of 2. For example, a search query containing
hellowill yield results with:- edit distance of 0:
hello - edit distance of 1: For example,
hllo(delete),helloo(add),hallo(modify).
- edit distance of 0:
[!note] Note Fuzzy search requires the admin to set
REPO_INDEXER_FUZZY_ENABLED.
Scope
Please note that when using the repository indexer, search results are limited to the contents of the default branch of each repository.
Similar to basic search, searching within a directory (or file) is also possible for advanced search.
However, unlike basic search, the search is more granular as it applies the filter but selectively includes/excludes files depending on REPO_INDEXER_INCLUDE/REPO_INDEXER_EXCLUDE.
Issue Search
Since v11, Issue search on Forgejo replaced its previously dropdown-defined behavior of searches with a query syntax defined by operators.
Query Syntax
Keywords
- Terms
Performs a fuzzy match search of each term in the query.
For example,
foowill return results that containfoo, or any of its derivatives (such asfororfood)foo barwill return results that containfooand/orbaror any of their derivatives
- Phrase
Performs an exact match for the provided phrase. This is done by wrapping the phrase in double quotes.
For example,
"foo"will return results that contain an exact match offoo"foo bar"will return results that contain an exact match offoo bar
Operators
- Negation
Negates the keyword by returning results that do not contain the keyword. This is done by prefixing the keyword with a minus symbol.
For example,
-foowill return results that do not containfooor its derivatives-"foo bar"will return results that do not containfoo bar
- Required
Denotes that the provided keyword MUST be present. This is done by prefixing the keyword with a plus symbol.
For example,
+foo +barwill return results that contain bothfooandbar(or its fuzzy derivatives)+"foo" +"bar"will return results that contain exactly bothfooandbar+"foo bar" +"baz"will return results that contain exactly bothfoo barandbaz
Escaping
All operators may be escaped by adding a backslash in front of the operators.
For example,
"\"\""will search for""\+1will search for+1
Filters
Filters listed below may be escaped by using a phrase search. For example, "is:open".
State
These filters are mutually exclusive. If multiple state filters are used, then the rightmost filter takes precedence.
| Filter | Description |
|---|---|
is:open or -is:closed |
Filters issues/pull requests that are open |
is:closed or -is:open |
Filters issues/pull requests that are closed |
is:all |
Filters issues/pull requests that are either open or closed |
Examples,
is:open +"bug": Searches forbugamong open issues/PRs.is:all -"backport": Search for all issues/PRs that do not contain the term "backport"."is:all": Literal search foris:all. Matches Issues/PRs that contain the termis:all.
User
These filter issues/pull requests by a username.
| Filter | Description |
|---|---|
author:* |
Authored By |
assignee:* |
Assigned To |
review:* |
Reviewed By |
mentions:* |
Mentions the user |
Examples,
Misc.
| Filter | Description |
|---|---|
sort:<by>:[asc/desc] |
Sorts issues/PRs. Where, <by> is one of created, comments, updated, deadline |
modified:[>/<]<date> |
Last updated date in ISO format |
Examples,
sort:created:desc is:all: Sort by the latest issues/PRs.sort:comments:desc: Sort by the most commented issues.modified:>2025-12-05: Searches for issues/PRs modified after2025-12-05.modified:2025-12-05: Searches for issues/PRs modified exactly on2025-12-05.modified:<2025-12-05: Searches for issues/PRs modified before2025-12-05.