Fix some bugs in full-text search

This commit is contained in:
2024-12-18 09:15:58 +08:00
parent 05df3fa376
commit 3f1e302d6b
2 changed files with 10 additions and 4 deletions

View File

@@ -372,9 +372,15 @@ func (ma *MApp) SearchHandler(ctx *gin.Context) {
nxtPage = allPage
}
// generate search posts
start := (curPage - 1) * size
offset := curPage * size
var resultPosts []model.MPost
for _, searchPost := range searchPosts {
resultPosts = append(resultPosts, *ma.IndexedPosts[searchPost.DocId])
if len(searchPosts) > 0 {
for i := start; i < utils.Min(len(searchPosts), offset); i++ {
resultPosts = append(resultPosts, *ma.IndexedPosts[searchPosts[i].DocId])
}
}
resData := gin.H{