You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
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>
11 months ago
..
install Implement FSFE REUSE for golang files (#21840) 2 years ago
paginator Implement FSFE REUSE for golang files (#21840) 2 years ago
common.go Refactor and enhance issue indexer to support both searching, filtering and paging (#26012) 11 months ago
consistency.go Implement FSFE REUSE for golang files (#21840) 2 years ago
context.go Replace `interface{}` with `any` (#25686) 1 year ago
context_committer_test.go Fix halfCommitter and WithTx (#22366) 2 years ago
context_test.go Always reuse transaction (#22362) 2 years ago
convert.go Support converting varchar to nvarchar for mssql database (#24105) 1 year ago
engine.go Replace `interface{}` with `any` (#25686) 1 year ago
engine_test.go Check primary keys for all tables and drop ForeignReference (#21721) 2 years ago
error.go Replace `interface{}` with `any` (#25686) 1 year ago
index.go Fix index generation parallelly failure (#25235) 1 year ago
index_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
iterate.go Implement FSFE REUSE for golang files (#21840) 2 years ago
iterate_test.go Allow adding new files to an empty repo (#24164) 1 year ago
list.go Fix db.Find bug (#23115) 1 year ago
list_test.go Use more specific test methods (#24265) 1 year ago
log.go Replace `interface{}` with `any` (#25686) 1 year ago
main_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
name.go Implement FSFE REUSE for golang files (#21840) 2 years ago
search.go Split lfs size from repository size (#22900) 1 year ago
sequence.go Refactor `setting.Database.UseXXX` to methods (#23354) 1 year ago
sql_postgres_with_schema.go Fix .golangci.yml (#22868) 1 year ago