@@ -103,7 +103,7 @@ func InitIssueIndexer(syncReindex bool) {
103103 log .Fatal ("Unable to issueIndexer.Init with connection %s Error: %v" , setting .Indexer .IssueConnStr , err )
104104 }
105105 case "db" :
106- issueIndexer = db .NewIndexer ()
106+ issueIndexer = db .GetIndexer ()
107107 case "meilisearch" :
108108 issueIndexer = meilisearch .NewIndexer (setting .Indexer .IssueConnStr , setting .Indexer .IssueConnAuth , setting .Indexer .IssueIndexerName )
109109 existed , err = issueIndexer .Init (ctx )
@@ -291,19 +291,22 @@ func SearchIssues(ctx context.Context, opts *SearchOptions) ([]int64, int64, err
291291 // So if the user creates an issue and list issues immediately, the issue may not be listed because the indexer needs time to index the issue.
292292 // Even worse, the external indexer like elastic search may not be available for a while,
293293 // and the user may not be able to list issues completely until it is available again.
294- ix = db .NewIndexer ()
294+ ix = db .GetIndexer ()
295295 }
296+
296297 result , err := ix .Search (ctx , opts )
297298 if err != nil {
298299 return nil , 0 , err
299300 }
301+ return SearchResultToIDSlice (result ), result .Total , nil
302+ }
300303
304+ func SearchResultToIDSlice (result * internal.SearchResult ) []int64 {
301305 ret := make ([]int64 , 0 , len (result .Hits ))
302306 for _ , hit := range result .Hits {
303307 ret = append (ret , hit .ID )
304308 }
305-
306- return ret , result .Total , nil
309+ return ret
307310}
308311
309312// CountIssues counts issues by options. It is a shortcut of SearchIssues(ctx, opts) but only returns the total count.
0 commit comments