An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: `Move` supports searching by document block ID https://github.com/siyuan-note/siyuan/issues/16674
Daniel5cf09d8043f5
diff --git a/kernel/api/filetree.go b/kernel/api/filetree.goindex 39fdff05c6..3339dd6cc9 100644--- a/kernel/api/filetree.go+++ b/kernel/api/filetree.go@@ -1043,7 +1043,7 @@ func searchDocs(c *gin.Context) {}k := arg["k"].(string)- ret.Data = model.SearchDocsByKeyword(k, flashcard, excludeIDs)+ ret.Data = model.SearchDocs(k, flashcard, excludeIDs)}func listDocsByPath(c *gin.Context) {diff --git a/kernel/model/file.go b/kernel/model/file.goindex fba93a55d4..339bd4c4e9 100644--- a/kernel/model/file.go+++ b/kernel/model/file.go@@ -139,7 +139,7 @@ func (box *Box) moveCorruptedData(filePath string) {logging.LogWarnf("moved corrupted data file [%s] to [%s]", filePath, to)}-func SearchDocsByKeyword(keyword string, flashcard bool, excludeIDs []string) (ret []map[string]string) {+func SearchDocs(keyword string, flashcard bool, excludeIDs []string) (ret []map[string]string) {ret = []map[string]string{}var deck *riff.Deck@@ -159,48 +159,54 @@ func SearchDocsByKeyword(keyword string, flashcard bool, excludeIDs []string) (rboxes[box.ID] = box}- keywords := strings.Fields(keyword)+ keyword = strings.TrimSpace(keyword)+var rootBlocks []*sql.Block- if 0 < len(keywords) {- for _, box := range boxes {- if gulu.Str.Contains(box.Name, keywords) {- if flashcard {- newFlashcardCount, dueFlashcardCount, flashcardCount := countBoxFlashcard(box.ID, deck, deckBlockIDs)- if 0 < flashcardCount {- ret = append(ret, map[string]string{"path": "/", "hPath": box.Name + "/", "box": box.ID, "boxIcon": box.Icon, "newFlashcardCount": strconv.Itoa(newFlashcardCount), "dueFlashcardCount": strconv.Itoa(dueFlashcardCount), "flashcardCount": strconv.Itoa(flashcardCount)})+ if ast.IsNodeIDPattern(keyword) {+ rootBlocks = sql.QueryRootBlockByCondition("id='"+keyword+"'", 1)+ } else {+ keywords := strings.Fields(keyword)+ if 0 < len(keywords) {+ for _, box := range boxes {+ if gulu.Str.Contains(box.Name, keywords) {+ if flashcard {+ newFlashcardCount, dueFlashcardCount, flashcardCount := countBoxFlashcard(box.ID, deck, deckBlockIDs)+ if 0 < flashcardCount {+ ret = append(ret, map[string]string{"path": "/", "hPath": box.Name + "/", "box": box.ID, "boxIcon": box.Icon, "newFlashcardCount": strconv.Itoa(newFlashcardCount), "dueFlashcardCount": strconv.Itoa(dueFlashcardCount), "flashcardCount": strconv.Itoa(flashcardCount)})+ }+ } else {+ ret = append(ret, map[string]string{"path": "/", "hPath": box.Name + "/", "box": box.ID, "boxIcon": box.Icon})}- } else {- ret = append(ret, map[string]string{"path": "/", "hPath": box.Name + "/", "box": box.ID, "boxIcon": box.Icon})}}- }- var condition string- for i, k := range keywords {- condition += "(hpath LIKE '%" + k + "%'"- namCondition := Conf.Search.NAMFilter(k)- condition += " " + namCondition- condition += ")"+ var condition string+ for i, k := range keywords {+ condition += "(hpath LIKE '%" + k + "%'"+ namCondition := Conf.Search.NAMFilter(k)+ condition += " " + namCondition+ condition += ")"- if i < len(keywords)-1 {- condition += " AND "+ if i < len(keywords)-1 {+ condition += " AND "+ }}- }- for _, excludeID := range excludeIDs {- condition += fmt.Sprintf(" AND path NOT LIKE '%%%s%%' ", excludeID)- }+ for _, excludeID := range excludeIDs {+ condition += fmt.Sprintf(" AND path NOT LIKE '%%%s%%' ", excludeID)+ }- rootBlocks = sql.QueryRootBlockByCondition(condition, Conf.Search.Limit)- } else {- for _, box := range boxes {- if flashcard {- newFlashcardCount, dueFlashcardCount, flashcardCount := countBoxFlashcard(box.ID, deck, deckBlockIDs)- if 0 < flashcardCount {- ret = append(ret, map[string]string{"path": "/", "hPath": box.Name + "/", "box": box.ID, "boxIcon": box.Icon, "newFlashcardCount": strconv.Itoa(newFlashcardCount), "dueFlashcardCount": strconv.Itoa(dueFlashcardCount), "flashcardCount": strconv.Itoa(flashcardCount)})+ rootBlocks = sql.QueryRootBlockByCondition(condition, Conf.Search.Limit)+ } else {+ for _, box := range boxes {+ if flashcard {+ newFlashcardCount, dueFlashcardCount, flashcardCount := countBoxFlashcard(box.ID, deck, deckBlockIDs)+ if 0 < flashcardCount {+ ret = append(ret, map[string]string{"path": "/", "hPath": box.Name + "/", "box": box.ID, "boxIcon": box.Icon, "newFlashcardCount": strconv.Itoa(newFlashcardCount), "dueFlashcardCount": strconv.Itoa(dueFlashcardCount), "flashcardCount": strconv.Itoa(flashcardCount)})+ }+ } else {+ ret = append(ret, map[string]string{"path": "/", "hPath": box.Name + "/", "box": box.ID, "boxIcon": box.Icon})}- } else {- ret = append(ret, map[string]string{"path": "/", "hPath": box.Name + "/", "box": box.ID, "boxIcon": box.Icon})}}}