]> source.dussan.org Git - gitea.git/commit
Refactor and enhance issue indexer to support both searching, filtering and paging...
authorJason Song <i@wolfogre.com>
Mon, 31 Jul 2023 06:28:53 +0000 (14:28 +0800)
committerGitHub <noreply@github.com>
Mon, 31 Jul 2023 06:28:53 +0000 (06:28 +0000)
commit1e76a824bcd71acd59cdfb2c4547806bc34b3d86
treee92523a9c82bbb8d91035a44a36bab7ef981e162
parentaba9096999798efef448bee2f289917069f9b599
Refactor and enhance issue indexer to support both searching, filtering and paging (#26012)

Fix #24662.

Replace #24822 and #25708 (although it has been merged)

## Background

In the past, Gitea supported issue searching with a keyword and
conditions in a less efficient way. It worked by searching for issues
with the keyword and obtaining limited IDs (as it is heavy to get all)
on the indexer (bleve/elasticsearch/meilisearch), and then querying with
conditions on the database to find a subset of the found IDs. This is
why the results could be incomplete.

To solve this issue, we need to store all fields that could be used as
conditions in the indexer and support both keyword and additional
conditions when searching with the indexer.

## Major changes

- Redefine `IndexerData` to include all fields that could be used as
filter conditions.
- Refactor `Search(ctx context.Context, kw string, repoIDs []int64,
limit, start int, state string)` to `Search(ctx context.Context, options
*SearchOptions)`, so it supports more conditions now.
- Change the data type stored in `issueIndexerQueue`. Use
`IndexerMetadata` instead of `IndexerData` in case the data has been
updated while it is in the queue. This also reduces the storage size of
the queue.
- Enhance searching with Bleve/Elasticsearch/Meilisearch, make them
fully support `SearchOptions`. Also, update the data versions.
- Keep most logic of database indexer, but remove
`issues.SearchIssueIDsByKeyword` in `models` to avoid confusion where is
the entry point to search issues.
- Start a Meilisearch instance to test it in unit tests.
- Add unit tests with almost full coverage to test
Bleve/Elasticsearch/Meilisearch indexer.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
37 files changed:
.github/workflows/pull-db-tests.yml
models/db/common.go
models/issues/issue.go
models/issues/issue_search.go
models/issues/issue_test.go
models/issues/issue_user.go
models/issues/label.go
models/issues/milestone.go
modules/indexer/code/bleve/bleve.go
modules/indexer/internal/bleve/query.go [new file with mode: 0644]
modules/indexer/internal/elasticsearch/indexer.go
modules/indexer/internal/meilisearch/filter.go [new file with mode: 0644]
modules/indexer/internal/meilisearch/indexer.go
modules/indexer/internal/paginator.go [new file with mode: 0644]
modules/indexer/issues/bleve/bleve.go
modules/indexer/issues/bleve/bleve_test.go
modules/indexer/issues/db/db.go
modules/indexer/issues/db/options.go [new file with mode: 0644]
modules/indexer/issues/dboptions.go [new file with mode: 0644]
modules/indexer/issues/elasticsearch/elasticsearch.go
modules/indexer/issues/elasticsearch/elasticsearch_test.go [new file with mode: 0644]
modules/indexer/issues/indexer.go
modules/indexer/issues/indexer_test.go
modules/indexer/issues/internal/indexer.go
modules/indexer/issues/internal/model.go
modules/indexer/issues/internal/tests/tests.go [new file with mode: 0644]
modules/indexer/issues/meilisearch/meilisearch.go
modules/indexer/issues/meilisearch/meilisearch_test.go [new file with mode: 0644]
modules/indexer/issues/util.go [new file with mode: 0644]
modules/notification/indexer/indexer.go
modules/repository/create.go
routers/api/v1/repo/issue.go
routers/api/v1/repo/issue_label.go
routers/web/repo/issue.go
routers/web/user/home.go
routers/web/user/notification.go
tests/integration/issue_test.go