Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Global search supports pagination to display results https://github.com/siyuan-note/siyuan/issues/7948

Liang Dingc5c24994a865
diff --git a/kernel/api/search.go b/kernel/api/search.go
index 204158ffd8..dc8fc57e7a 100644
--- a/kernel/api/search.go
+++ b/kernel/api/search.go
@@ -267,12 +267,11 @@ func fullTextSearchBlock(c *gin.Context) {
if nil != groupByArg {
groupBy = int(groupByArg.(float64))
}
- blocks, matchedBlockCount, matchedRootCount, pageCount, totalCount := model.FullTextSearchBlock(query, boxes, paths, types, method, orderBy, groupBy, page)
+ blocks, matchedBlockCount, matchedRootCount, pageCount := model.FullTextSearchBlock(query, boxes, paths, types, method, orderBy, groupBy, page)
ret.Data = map[string]interface{}{
"blocks": blocks,
"matchedBlockCount": matchedBlockCount,
"matchedRootCount": matchedRootCount,
"pageCount": pageCount,
- "totalCount": totalCount,
}
}
diff --git a/kernel/model/search.go b/kernel/model/search.go
index 87a0e38ec4..4e72e182d6 100644
--- a/kernel/model/search.go
+++ b/kernel/model/search.go
@@ -397,7 +397,7 @@ const pageSize = 32
// method:0:关键字,1:查询语法,2:SQL,3:正则表达式
// orderBy: 0:按块类型(默认),1:按创建时间升序,2:按创建时间降序,3:按更新时间升序,4:按更新时间降序,5:按内容顺序(仅在按文档分组时),6:按相关度升序,7:按相关度降序
// groupBy:0:不分组,1:按文档分组
-func FullTextSearchBlock(query string, boxes, paths []string, types map[string]bool, method, orderBy, groupBy, page int) (ret []*Block, matchedBlockCount, matchedRootCount, pageCount, totalCount int) {
+func FullTextSearchBlock(query string, boxes, paths []string, types map[string]bool, method, orderBy, groupBy, page int) (ret []*Block, matchedBlockCount, matchedRootCount, pageCount int) {
query = strings.TrimSpace(query)
beforeLen := 36
var blocks []*Block
@@ -421,6 +421,7 @@ func FullTextSearchBlock(query string, boxes, paths []string, types map[string]b
pathFilter := buildPathsFilter(paths)
blocks, matchedBlockCount, matchedRootCount = fullTextSearchByKeyword(query, boxFilter, pathFilter, filter, orderByClause, beforeLen, page)
}
+ pageCount = (matchedBlockCount + pageSize - 1) / pageSize
switch groupBy {
case 0: // 不分组