aboutsummaryrefslogtreecommitdiffstats
path: root/modules/repository
diff options
context:
space:
mode:
authorJason Song <i@wolfogre.com>2023-07-31 14:28:53 +0800
committerGitHub <noreply@github.com>2023-07-31 06:28:53 +0000
commit1e76a824bcd71acd59cdfb2c4547806bc34b3d86 (patch)
treee92523a9c82bbb8d91035a44a36bab7ef981e162 /modules/repository
parentaba9096999798efef448bee2f289917069f9b599 (diff)
downloadgitea-1e76a824bcd71acd59cdfb2c4547806bc34b3d86.tar.gz
gitea-1e76a824bcd71acd59cdfb2c4547806bc34b3d86.zip
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>
Diffstat (limited to 'modules/repository')
-rw-r--r--modules/repository/create.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/repository/create.go b/modules/repository/create.go
index e8a1b8ba2b..10a1e872df 100644
--- a/modules/repository/create.go
+++ b/modules/repository/create.go
@@ -23,6 +23,7 @@ import (
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/models/webhook"
"code.gitea.io/gitea/modules/git"
+ issue_indexer "code.gitea.io/gitea/modules/indexer/issues"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
@@ -418,6 +419,10 @@ func UpdateRepository(ctx context.Context, repo *repo_model.Repository, visibili
return fmt.Errorf("updateRepository[%d]: %w", forkRepos[i].ID, err)
}
}
+
+ // If visibility is changed, we need to update the issue indexer.
+ // Since the data in the issue indexer have field to indicate if the repo is public or not.
+ issue_indexer.UpdateRepoIndexer(ctx, repo.ID)
}
return nil