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: Improve search
Daniel4d7bd111e107
diff --git a/kernel/model/search.go b/kernel/model/search.goindex 4fb207c550..fdba7db623 100644--- a/kernel/model/search.go+++ b/kernel/model/search.go@@ -1016,7 +1016,11 @@ func FullTextSearchBlock(query string, boxes, paths []string, types map[string]btypeFilter := buildTypeFilter(types)boxFilter := buildBoxesFilter(boxes)pathFilter := buildPathsFilter(paths)- blocks, matchedBlockCount, matchedRootCount = fullTextSearchByQuerySyntax(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderByClause, beforeLen, page, pageSize)+ if ast.IsNodeIDPattern(query) {+ blocks, matchedBlockCount, matchedRootCount = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+query+"'", beforeLen, page, pageSize)+ } else {+ blocks, matchedBlockCount, matchedRootCount = fullTextSearchByFTS(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderByClause, beforeLen, page, pageSize)+ }case 2: // SQLblocks, matchedBlockCount, matchedRootCount = searchBySQL(query, beforeLen, page, pageSize)case 3: // 正则表达式@@ -1028,12 +1032,16 @@ func FullTextSearchBlock(query string, boxes, paths []string, types map[string]btypeFilter := buildTypeFilter(types)boxFilter := buildBoxesFilter(boxes)pathFilter := buildPathsFilter(paths)- if 2 > len(strings.Split(strings.TrimSpace(query), " ")) {- query = stringQuery(query)- blocks, matchedBlockCount, matchedRootCount = fullTextSearchByQuerySyntax(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderByClause, beforeLen, page, pageSize)+ if ast.IsNodeIDPattern(query) {+ blocks, matchedBlockCount, matchedRootCount = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+query+"'", beforeLen, page, pageSize)} else {- docMode = true // 文档全文搜索模式 https://github.com/siyuan-note/siyuan/issues/10584- blocks, matchedBlockCount, matchedRootCount = fullTextSearchByKeyword(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderByClause, beforeLen, page, pageSize)+ if 2 > len(strings.Split(strings.TrimSpace(query), " ")) {+ query = stringQuery(query)+ blocks, matchedBlockCount, matchedRootCount = fullTextSearchByFTS(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderByClause, beforeLen, page, pageSize)+ } else {+ docMode = true // 文档全文搜索模式 https://github.com/siyuan-note/siyuan/issues/10584+ blocks, matchedBlockCount, matchedRootCount = fullTextSearchByLikeWithRoot(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderByClause, beforeLen, page, pageSize)+ }}}pageCount = (matchedBlockCount + pageSize - 1) / pageSize@@ -1367,22 +1375,6 @@ func extractID(content string) (ret string) {return}-func fullTextSearchByQuerySyntax(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderBy string, beforeLen, page, pageSize int) (ret []*Block, matchedBlockCount, matchedRootCount int) {- if ast.IsNodeIDPattern(query) {- ret, matchedBlockCount, matchedRootCount = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+query+"'", beforeLen, page, pageSize)- return- }- return fullTextSearchByFTS(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderBy, beforeLen, page, pageSize)-}--func fullTextSearchByKeyword(query, boxFilter, pathFilter, typeFilter, ignoreFilter string, orderBy string, beforeLen, page, pageSize int) (ret []*Block, matchedBlockCount, matchedRootCount int) {- if ast.IsNodeIDPattern(query) {- ret, matchedBlockCount, matchedRootCount = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+query+"'", beforeLen, page, pageSize)- return- }- return fullTextSearchByLikeWithRoot(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderBy, beforeLen, page, pageSize)-}-func fullTextSearchByRegexp(exp, boxFilter, pathFilter, typeFilter, ignoreFilter, orderBy string, beforeLen, page, pageSize int) (ret []*Block, matchedBlockCount, matchedRootCount int) {fieldFilter := fieldRegexp(exp)stmt := "SELECT * FROM `blocks` WHERE " + fieldFilter + " AND type IN " + typeFilter