Skip to content

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

:zap: Improve global searching (group by doc) performance https://github.com/siyuan-note/siyuan/issues/11951

Danielc79b56aef022
diff --git a/kernel/model/search.go b/kernel/model/search.go
index 88490ffdc5..e5cb90c548 100644
--- a/kernel/model/search.go
+++ b/kernel/model/search.go
@@ -328,6 +328,7 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int, isSquareBrackets,
for _, ref := range refs {
btsID = append(btsID, ref.DefBlockRootID)
}
+ btsID = gulu.Str.RemoveDuplicatedElem(btsID)
bts := treenode.GetBlockTrees(btsID)
for _, ref := range refs {
tree := cachedTrees[ref.DefBlockRootID]
@@ -369,6 +370,7 @@ func SearchRefBlock(id, rootID, keyword string, beforeLen int, isSquareBrackets,
for _, b := range ret {
btsID = append(btsID, b.RootID)
}
+ btsID = gulu.Str.RemoveDuplicatedElem(btsID)
bts := treenode.GetBlockTrees(btsID)
for _, b := range ret {
tree := cachedTrees[b.RootID]
@@ -899,11 +901,17 @@ func FullTextSearchBlock(query string, boxes, paths []string, types map[string]b
rootMap := map[string]bool{}
var rootIDs []string
contentSorts := map[string]int{}
+ var btsID []string
+ for _, b := range blocks {
+ btsID = append(btsID, b.RootID)
+ }
+ btsID = gulu.Str.RemoveDuplicatedElem(btsID)
+ bts := treenode.GetBlockTrees(btsID)
for _, b := range blocks {
if _, ok := rootMap[b.RootID]; !ok {
rootMap[b.RootID] = true
rootIDs = append(rootIDs, b.RootID)
- tree, _ := LoadTreeByBlockID(b.RootID)
+ tree, _ := loadTreeByBlockTree(bts[b.RootID])
if nil == tree {
continue
}