forgejo/models
Jason Song 1e76a824bc
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>
2023-07-31 06:28:53 +00:00
..
actions Fix wrong workflow status when rerun a job in an already finished workflow (#26119) 2023-07-25 09:13:36 +00:00
activities Add context parameter to some database functions (#26055) 2023-07-22 22:14:27 +08:00
admin Replace interface{} with any (#25686) 2023-07-04 18:36:08 +00:00
asymkey Update tool dependencies, lock govulncheck and actionlint (#25655) 2023-07-09 11:58:06 +00:00
auth Remove "misc" scope check from public API endpoints (#26134) 2023-07-26 02:53:31 +00:00
avatars Avoid warning for system setting when start up (#23054) 2023-02-24 18:23:13 +08:00
db Refactor and enhance issue indexer to support both searching, filtering and paging (#26012) 2023-07-31 06:28:53 +00:00
dbfs Fix content holes in Actions task logs file (#25560) 2023-06-28 19:07:29 +02:00
fixtures Fix access check for org-level project (#26182) 2023-07-29 14:13:24 +00:00
git Fix pull request check list is limited (#26179) 2023-07-31 02:21:09 +00:00
issues Refactor and enhance issue indexer to support both searching, filtering and paging (#26012) 2023-07-31 06:28:53 +00:00
migrations Fix typo in metadata (#26207) 2023-07-30 23:54:22 +00:00
organization Remove unused code (#25734) 2023-07-06 21:52:41 +00:00
packages Test if container blob is accessible before mounting (#22759) 2023-07-09 11:24:43 +00:00
perm some less naked returns (#25682) 2023-07-04 15:52:33 +00:00
project Update xorm version (#26128) 2023-07-25 20:27:44 +00:00
pull refactor some functions to support ctx as first parameter (#21878) 2022-12-03 10:48:26 +08:00
repo Add commits dropdown in PR files view and allow commit by commit review (#25528) 2023-07-28 21:18:12 +02:00
secret Support configuration variables on Gitea Actions (#24724) 2023-06-20 22:54:15 +00:00
shared/types Display owner of a runner as a tooltip instead of static text (#24377) 2023-05-12 08:43:27 +00:00
system Replace interface{} with any (#25686) 2023-07-04 18:36:08 +00:00
unit Rewrite logger system (#24726) 2023-05-21 22:35:11 +00:00
unittest Replace interface{} with any (#25686) 2023-07-04 18:36:08 +00:00
user Fix API leaking Usermail if not logged in (#25097) 2023-07-31 01:18:38 +00:00
webhook Replace interface{} with any (#25686) 2023-07-04 18:36:08 +00:00
error.go Sync branches into databases (#22743) 2023-06-29 10:03:20 +00:00
fixture_generation.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
fixture_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
main_test.go Merge setting.InitXXX into one function with options (#24389) 2023-05-04 11:55:35 +08:00
migrate.go Add context parameter to some database functions (#26055) 2023-07-22 22:14:27 +08:00
migrate_test.go Add context parameter to some database functions (#26055) 2023-07-22 22:14:27 +08:00
org.go refactor some functions to support ctx as first parameter (#21878) 2022-12-03 10:48:26 +08:00
org_team.go Remove org users who belong to no teams (#24247) 2023-04-24 15:52:38 -04:00
org_team_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
org_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
repo.go Update tool dependencies, lock govulncheck and actionlint (#25655) 2023-07-09 11:58:06 +00:00
repo_collaboration.go refactor some functions to support ctx as first parameter (#21878) 2022-12-03 10:48:26 +08:00
repo_collaboration_test.go Rename repo.GetOwner to repo.LoadOwner (#22967) 2023-02-18 20:11:03 +08:00
repo_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
repo_transfer.go Fix unclear IsRepositoryExist logic (#24374) 2023-04-28 14:14:26 -04:00
repo_transfer_test.go Rename almost all Ctx functions (#22071) 2022-12-10 10:46:31 +08:00