返回介绍

Repository indexer

发布于 2021-03-20 13:44:26 字数 2863 浏览 1039 评论 0 收藏 0

Table of Contents

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
UPDATE_BUFFER_LEN = 20
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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文