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: 搜索自定义属性改为搜索全部属性 https://github.com/siyuan-note/siyuan/issues/7367
Liang Dingd1f493e2d2cc
diff --git a/kernel/model/search.go b/kernel/model/search.goindex 2a722ea805..05cea66083 100644--- a/kernel/model/search.go+++ b/kernel/model/search.go@@ -591,7 +591,6 @@ func fullTextSearchRefBlock(keyword string, beforeLen int) (ret []*Block) {"snippet(" + table + ", 11, '" + search.SearchMarkLeft + "', '" + search.SearchMarkRight + "', '...', 64) AS content, " +"fcontent, markdown, length, type, subtype, ial, sort, created, updated"stmt := "SELECT " + projections + " FROM " + table + " WHERE " + table + " MATCH '" + columnFilter() + ":(" + quotedKeyword + ")' AND type IN " + Conf.Search.TypeFilter()- stmt = customIALFilter(quotedKeyword)orderBy := ` order by casewhen name = '${keyword}' then 10when alias = '${keyword}' then 20@@ -609,7 +608,7 @@ func fullTextSearchRefBlock(keyword string, beforeLen int) (ret []*Block) {else 65535 end ASC, sort ASC, length ASC`orderBy = strings.ReplaceAll(orderBy, "${keyword}", keyword)stmt += orderBy + " LIMIT " + strconv.Itoa(Conf.Search.Limit)- blocks := sql.SelectBlocksRawStmt(stmt, Conf.Search.Limit)+ blocks := sql.SelectBlocksRawStmtNoParse(stmt, Conf.Search.Limit)ret = fromSQLBlocks(&blocks, "", beforeLen)if 1 > len(ret) {ret = []*Block{}@@ -645,7 +644,7 @@ func fullTextSearchByRegexp(exp, boxFilter, pathFilter, typeFilter, orderBy stristmt += boxFilter + pathFilterstmt += " " + orderBystmt += " LIMIT " + strconv.Itoa(Conf.Search.Limit)- blocks := sql.SelectBlocksRawStmt(stmt, Conf.Search.Limit)+ blocks := sql.SelectBlocksRawStmtNoParse(stmt, Conf.Search.Limit)ret = fromSQLBlocks(&blocks, "", beforeLen)if 1 > len(ret) {ret = []*Block{}@@ -683,7 +682,6 @@ func fullTextSearchByFTS(query, boxFilter, pathFilter, typeFilter, orderBy strin"highlight(" + table + ", 11, '" + search.SearchMarkLeft + "', '" + search.SearchMarkRight + "') AS content, " +"fcontent, markdown, length, type, subtype, ial, sort, created, updated"stmt := "SELECT " + projections + " FROM " + table + " WHERE (`" + table + "` MATCH '" + columnFilter() + ":(" + query + ")'"- stmt += customIALFilter(query)stmt += ") AND type IN " + typeFilterstmt += boxFilter + pathFilterstmt += " " + orderBy@@ -716,7 +714,6 @@ func fullTextSearchCount(query, boxFilter, pathFilter, typeFilter string) (match}stmt := "SELECT COUNT(id) AS `matches`, COUNT(DISTINCT(root_id)) AS `docs` FROM `" + table + "` WHERE (`" + table + "` MATCH '" + columnFilter() + ":(" + query + ")'"- stmt += customIALFilter(query)stmt += ") AND type IN " + typeFilterstmt += boxFilter + pathFilterresult, _ := sql.Query(stmt)@@ -728,20 +725,6 @@ func fullTextSearchCount(query, boxFilter, pathFilter, typeFilter string) (matchreturn}-// customIALFilter 用于组装自定义属性过滤条件。-// 打开自定义属性搜索选项后出现多余搜索结果 https://github.com/siyuan-note/siyuan/issues/7367-func customIALFilter(query string) string {- if !Conf.Search.Custom {- return ""- }-- reg := strings.TrimPrefix(query, "\"")- reg = strings.TrimSuffix(reg, "\"")- reg = regexp.QuoteMeta(reg)- reg = "custom-.*" + reg + ".*"- return " OR ial REGEXP '" + reg + "'"-}-func markSearch(text string, keyword string, beforeLen int) (marked string, score float64) {if 0 == len(keyword) {marked = text@@ -906,6 +889,9 @@ func columnFilter() string {if Conf.Search.Memo {buf.WriteString(" memo")}+ if Conf.Search.Custom {+ buf.WriteString(" ial")+ }buf.WriteString(" tag}")return buf.String()}