Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/15777

Daniela4f03191fa8d
diff --git a/kernel/model/file.go b/kernel/model/file.go
index fb9b77265c..567db81101 100644
--- a/kernel/model/file.go
+++ b/kernel/model/file.go
@@ -187,7 +187,7 @@ func SearchDocsByKeyword(keyword string, flashcard bool) (ret []map[string]strin
}
}
- rootBlocks = sql.QueryRootBlockByCondition(condition)
+ rootBlocks = sql.QueryRootBlockByCondition(condition, Conf.Search.Limit)
} else {
for _, box := range boxes {
if flashcard {
diff --git a/kernel/sql/block_query.go b/kernel/sql/block_query.go
index 578f4300ab..2ba4f645b0 100644
--- a/kernel/sql/block_query.go
+++ b/kernel/sql/block_query.go
@@ -69,8 +69,8 @@ func queryBlockHashes(rootID string) (ret map[string]string) {
return
}
-func QueryRootBlockByCondition(condition string) (ret []*Block) {
- sqlStmt := "SELECT *, length(hpath) - length(replace(hpath, '/', '')) AS lv FROM blocks WHERE type = 'd' AND " + condition + " ORDER BY box DESC,lv ASC LIMIT 128"
+func QueryRootBlockByCondition(condition string, limit int) (ret []*Block) {
+ sqlStmt := "SELECT *, length(hpath) - length(replace(hpath, '/', '')) AS lv FROM blocks WHERE type = 'd' AND " + condition + " ORDER BY box DESC,lv ASC LIMIT " + strconv.Itoa(limit)
rows, err := query(sqlStmt)
if err != nil {
logging.LogErrorf("sql query [%s] failed: %s", sqlStmt, err)