mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-04 08:17:24 -05:00
Fix meilisearch not working when searching across multiple repositories (#24109)
This would happen in the issue and pull request dashboards, while the per repository lists worked fine. Use OR instead of AND for repo IDs.
This commit is contained in:
parent
1c8bc4081a
commit
b667634b32
@ -6,6 +6,7 @@ package issues
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -120,10 +121,11 @@ func (b *MeilisearchIndexer) Delete(ids ...int64) error {
|
|||||||
// Search searches for issues by given conditions.
|
// Search searches for issues by given conditions.
|
||||||
// Returns the matching issue IDs
|
// Returns the matching issue IDs
|
||||||
func (b *MeilisearchIndexer) Search(ctx context.Context, keyword string, repoIDs []int64, limit, start int) (*SearchResult, error) {
|
func (b *MeilisearchIndexer) Search(ctx context.Context, keyword string, repoIDs []int64, limit, start int) (*SearchResult, error) {
|
||||||
filter := make([][]string, 0, len(repoIDs))
|
repoFilters := make([]string, 0, len(repoIDs))
|
||||||
for _, repoID := range repoIDs {
|
for _, repoID := range repoIDs {
|
||||||
filter = append(filter, []string{"repo_id = " + strconv.FormatInt(repoID, 10)})
|
repoFilters = append(repoFilters, "repo_id = "+strconv.FormatInt(repoID, 10))
|
||||||
}
|
}
|
||||||
|
filter := strings.Join(repoFilters, " OR ")
|
||||||
searchRes, err := b.client.Index(b.indexerName).Search(keyword, &meilisearch.SearchRequest{
|
searchRes, err := b.client.Index(b.indexerName).Search(keyword, &meilisearch.SearchRequest{
|
||||||
Filter: filter,
|
Filter: filter,
|
||||||
Limit: int64(limit),
|
Limit: int64(limit),
|
||||||
|
Loading…
Reference in New Issue
Block a user