An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: 打开自定义属性搜索选项后出现多余搜索结果 Fix https://github.com/siyuan-note/siyuan/issues/7367
Liang Dingb1a78149f2c7
diff --git a/kernel/conf/search.go b/kernel/conf/search.goindex da9cd05c9a..eecf421f37 100644--- a/kernel/conf/search.go+++ b/kernel/conf/search.go@@ -108,9 +108,6 @@ func (s *Search) NAMFilter(keyword string) string {if s.Memo {buf.WriteString(" OR memo LIKE '%" + keyword + "%'")}- if s.Custom {- buf.WriteString(" OR ial LIKE '%=%" + keyword + "%'")- }return buf.String()}diff --git a/kernel/model/search.go b/kernel/model/search.goindex ee6fa12b45..ad0abc480a 100644--- a/kernel/model/search.go+++ b/kernel/model/search.go@@ -683,6 +683,7 @@ func fullTextSearchByFTS(query, boxFilter, pathFilter, typeFilter, orderBy strin"fcontent, markdown, length, type, subtype, ial, sort, created, updated"stmt := "SELECT " + projections + " FROM " + table + " WHERE " + table + " MATCH '" + columnFilter() + ":(" + query + ")' AND type IN " + typeFilterstmt += boxFilter + pathFilter+ stmt += customIALFilter(query)stmt += " " + orderBystmt += " LIMIT " + strconv.Itoa(Conf.Search.Limit)blocks := sql.SelectBlocksRawStmt(stmt, Conf.Search.Limit)@@ -714,6 +715,7 @@ func fullTextSearchCount(query, boxFilter, pathFilter, typeFilter string) (matchstmt := "SELECT COUNT(id) AS `matches`, COUNT(DISTINCT(root_id)) AS `docs` FROM `" + table + "` WHERE `" + table + "` MATCH '" + columnFilter() + ":(" + query + ")' AND type IN " + typeFilterstmt += boxFilter + pathFilter+ stmt += customIALFilter(query)result, _ := sql.Query(stmt)if 1 > len(result) {return@@ -723,6 +725,20 @@ 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 " AND ial REGEXP '" + reg + "'"+}+func markSearch(text string, keyword string, beforeLen int) (marked string, score float64) {if 0 == len(keyword) {marked = text