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: SQL 搜索支持多个搜索关键字匹配文档 Fix https://github.com/siyuan-note/siyuan/issues/7350
Liang Ding1754dee724fa
diff --git a/kernel/model/search.go b/kernel/model/search.goindex 9d0b60ccb2..ee6fa12b45 100644--- a/kernel/model/search.go+++ b/kernel/model/search.go@@ -544,6 +544,7 @@ func buildTypeFilter(types map[string]bool) string {func searchBySQL(stmt string, beforeLen int) (ret []*Block, matchedBlockCount, matchedRootCount int) {stmt = gulu.Str.RemoveInvisible(stmt)+ stmt = strings.TrimSpace(stmt)blocks := sql.SelectBlocksRawStmt(stmt, Conf.Search.Limit)ret = fromSQLBlocks(&blocks, "", beforeLen)if 1 > len(ret) {@@ -552,7 +553,11 @@ func searchBySQL(stmt string, beforeLen int) (ret []*Block, matchedBlockCount, m}stmt = strings.ToLower(stmt)- stmt = strings.ReplaceAll(stmt, "select * ", "select COUNT(id) AS `matches`, COUNT(DISTINCT(root_id)) AS `docs` ")+ if strings.HasPrefix(stmt, "select a.* ") { // 多个搜索关键字匹配文档 https://github.com/siyuan-note/siyuan/issues/7350+ stmt = strings.ReplaceAll(stmt, "select a.* ", "select COUNT(a.id) AS `matches`, COUNT(DISTINCT(a.root_id)) AS `docs` ")+ } else {+ stmt = strings.ReplaceAll(stmt, "select * ", "select COUNT(id) AS `matches`, COUNT(DISTINCT(root_id)) AS `docs` ")+ }result, _ := sql.Query(stmt)if 1 > len(ret) {return