From 6cc672040ba19d73cdeb46acc7b4cd38a9ec2ca2 Mon Sep 17 00:00:00 2001 From: Shiny Nematoda Date: Thu, 29 Feb 2024 15:06:38 +0000 Subject: [PATCH] admin: Document fallback behavior of repo indexer (#444) ref: https://codeberg.org/forgejo/forgejo/pulls/1594 Preview: https://forgejo.codeberg.page/@docs_pull_444/docs/next/user/code-search/ Reviewed-on: https://codeberg.org/forgejo/docs/pulls/444 Reviewed-by: Earl Warren Co-authored-by: Shiny Nematoda Co-committed-by: Shiny Nematoda --- docs/admin/config-cheat-sheet.md | 2 +- docs/user/code-search.md | 16 ++++++++++++++++ docs/user/index.md | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 docs/user/code-search.md diff --git a/docs/admin/config-cheat-sheet.md b/docs/admin/config-cheat-sheet.md index 808bc025..9ad8e8e2 100644 --- a/docs/admin/config-cheat-sheet.md +++ b/docs/admin/config-cheat-sheet.md @@ -464,7 +464,7 @@ relation to port exhaustion. - `ISSUE_INDEXER_NAME`: **gitea_issues**: Issue indexer name, available when ISSUE_INDEXER_TYPE is elasticsearch or meilisearch. - `ISSUE_INDEXER_PATH`: **indexers/issues.bleve**: Index file used for issue search; available when ISSUE*INDEXER_TYPE is bleve and elasticsearch. Relative paths will be made absolute against *`AppWorkPath`\_. -- `REPO_INDEXER_ENABLED`: **false**: Enables code search (uses a lot of disk space, about 6 times more than the repository size). +- `REPO_INDEXER_ENABLED`: **false**: Enables code search (uses a lot of disk space, about 6 times more than the repository size). If disabled, code search will be limited within a single repository. - `REPO_INDEXER_REPO_TYPES`: **sources,forks,mirrors,templates**: Repo indexer units. The items to index could be `sources`, `forks`, `mirrors`, `templates` or any combination of them separated by a comma. If empty then it defaults to `sources` only, as if you'd like to disable fully please see `REPO_INDEXER_ENABLED`. - `REPO_INDEXER_TYPE`: **bleve**: Code search engine type, could be `bleve` or `elasticsearch`. - `REPO_INDEXER_PATH`: **indexers/repos.bleve**: Index file used for code search. diff --git a/docs/user/code-search.md b/docs/user/code-search.md new file mode 100644 index 00000000..db42db7d --- /dev/null +++ b/docs/user/code-search.md @@ -0,0 +1,16 @@ +--- +title: 'Code Search' +license: 'CC-BY-SA-4.0' +--- + +Forgejo supports code search through an indexer and `git-grep` as a fallback when [`REPO_INDEXER_ENABLED`](../../admin/config-cheat-sheet#indexer-indexer) is disabled. + +# Basic (git-grep) + +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). + +Currently, only fixed strings are supported and any case differences are ignored. The search results will include the matched line, as well as a single line before and after the match. The search query will be executed on the default branch of the repository. + +# Indexer + +For advanced search queries and searching across an entire organisation or instance, `REPO_INDEXER_ENABLED: true` enables code search via bleve/elasticsearch. diff --git a/docs/user/index.md b/docs/user/index.md index dd5693ee..e8b3b5eb 100644 --- a/docs/user/index.md +++ b/docs/user/index.md @@ -35,6 +35,7 @@ involved in running it on their machines. - [Merge Message templates](./merge-message-templates/) - [Webhooks](./webhooks/) - [Programming language detection](./language-detection/) + - [Code Search](./code-search/) - Authentication - [Generating an Access Token](https://docs.codeberg.org/advanced/access-token/) - [Access Token scope](./token-scope/)