]> source.dussan.org Git - gitea.git/commit
Fix issues indexer document mapping (#25619)
authorJason Song <i@wolfogre.com>
Tue, 4 Jul 2023 09:05:28 +0000 (17:05 +0800)
committerGitHub <noreply@github.com>
Tue, 4 Jul 2023 09:05:28 +0000 (09:05 +0000)
commit9958642502f8b505f97589d7a7f5357e8dfc04e3
treee9731af468ee4a4c9a600a1a51e44eb41dfb2f1d
parentdae022ab2a25e82cf89027f865c142ebdff0b5ea
Fix issues indexer document mapping (#25619)

Fix regression of #5363 (so long ago).

The old code definded a document mapping for `issueIndexerDocType`, and
assigned it to `BleveIndexerData` as its type. (`BleveIndexerData` has
been renamed to `IndexerData` in #25174, but nothing more.) But the old
code never used `BleveIndexerData`, it wrote the index with an anonymous
struct type. Nonetheless, bleve would use the default auto-mapping for
struct it didn't know, so the indexer still worked. This means the
custom document mapping was always dead code.

The custom document mapping is not useless, it can reduce index storage,
this PR brings it back and disable default mapping to prevent it from
happening again. Since `IndexerData`(`BleveIndexerData`) has JSON tags,
and bleve uses them first, so we should use `repo_id` as the field name
instead of `RepoID`.

I did a test to compare the storage size before and after this, with
about 3k real comments that were migrated from some public repos.

Before:

```text
[ 160]  .
├── [  42]  index_meta.json
├── [  13]  rupture_meta.json
└── [ 128]  store
    ├── [6.9M]  00000000005d.zap
    └── [256K]  root.bolt
```

After:

```text
[ 160]  .
├── [  42]  index_meta.json
├── [  13]  rupture_meta.json
└── [ 128]  store
    ├── [3.5M]  000000000065.zap
    └── [256K]  root.bolt
```

It saves about half the storage space.

---------

Co-authored-by: Giteabot <teabot@gitea.io>
modules/indexer/issues/bleve/bleve.go