1
1
mirror of https://github.com/go-gitea/gitea synced 2024-11-09 11:44:27 +00:00
gitea/docs/content/administration/repo-indexer.en-us.md
wxiaoguang 4734d43e14
Support repo code search without setting up an indexer (#29998)
By using git's ability, end users (especially small instance users) do
not need to enable the indexer, they could also benefit from the code
searching feature.

Fix #29996


![image](https://github.com/go-gitea/gitea/assets/2114189/11b7e458-88a4-480d-b4d7-72ee59406dd1)


![image](https://github.com/go-gitea/gitea/assets/2114189/0fe777d5-c95c-4288-a818-0427680805b6)

---------

Co-authored-by: silverwind <me@silverwind.io>
2024-03-24 17:05:00 +01:00

2.9 KiB

date title slug sidebar_position toc draft aliases menu
2019-09-06T01:35:00-03:00 Repository indexer repo-indexer 45 false false
/en-us/repo-indexer
sidebar
parent name sidebar_position identifier
administration Repository indexer 45 repo-indexer

Repository indexer

Builtin repository code search without indexer

Users could do repository-level code search without setting up a repository indexer. The builtin code search is based on the git grep command, which is fast and efficient for small repositories. Better code search support could be achieved by setting up the repository indexer.

Setting up the repository indexer

Gitea can search through the files of the repositories by enabling this function in your app.ini:

[indexer]
; ...
REPO_INDEXER_ENABLED = true
REPO_INDEXER_PATH = indexers/repos.bleve
MAX_FILE_SIZE = 1048576
REPO_INDEXER_INCLUDE =
REPO_INDEXER_EXCLUDE = resources/bin/**

Please bear in mind that indexing the contents can consume a lot of system resources, especially when the index is created for the first time or globally updated (e.g. after upgrading Gitea).

Choosing the files for indexing by size

The MAX_FILE_SIZE option will make the indexer skip all files larger than the specified value.

Choosing the files for indexing by path

Gitea applies glob pattern matching from the gobwas/glob library to choose which files will be included in the index.

Limiting the list of files prevents the indexes from becoming polluted with derived or irrelevant files (e.g. lss, sym, map, etc.), so the search results are more relevant. It can also help reduce the index size.

REPO_INDEXER_EXCLUDE_VENDORED (default: true) excludes vendored files from index.

REPO_INDEXER_INCLUDE (default: empty) is a comma separated list of glob patterns to include in the index. An empty list means "include all files". REPO_INDEXER_EXCLUDE (default: empty) is a comma separated list of glob patterns to exclude from the index. Files that match this list will not be indexed. REPO_INDEXER_EXCLUDE takes precedence over REPO_INDEXER_INCLUDE.

Pattern matching works as follows:

  • To match all files with a .txt extension no matter what directory, use **.txt.
  • To match all files with a .txt extension only at the root level of the repository, use *.txt.
  • To match all files inside resources/bin and below, use resources/bin/**.
  • To match all files immediately inside resources/bin, use resources/bin/*.
  • To match all files named Makefile, use **Makefile.
  • Matching a directory has no effect; the pattern resources/bin will not include/exclude files inside that directory; resources/bin/** will.
  • All files and patterns are normalized to lower case, so **Makefile, **makefile and **MAKEFILE are equivalent.