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 Ding5371da84aae0
diff --git a/kernel/model/search.go b/kernel/model/search.goindex 0b62bd1fcf..2a722ea805 100644--- a/kernel/model/search.go+++ b/kernel/model/search.go@@ -591,6 +591,7 @@ 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@@ -681,9 +682,10 @@ func fullTextSearchByFTS(query, boxFilter, pathFilter, typeFilter, orderBy strin"tag, " +"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 + ")' AND type IN " + typeFilter- stmt += boxFilter + pathFilter+ stmt := "SELECT " + projections + " FROM " + table + " WHERE (`" + table + "` MATCH '" + columnFilter() + ":(" + query + ")'"stmt += customIALFilter(query)+ stmt += ") AND type IN " + typeFilter+ stmt += boxFilter + pathFilterstmt += " " + orderBystmt += " LIMIT " + strconv.Itoa(Conf.Search.Limit)blocks := sql.SelectBlocksRawStmt(stmt, Conf.Search.Limit)@@ -713,9 +715,10 @@ func fullTextSearchCount(query, boxFilter, pathFilter, typeFilter string) (matchtable = "blocks_fts_case_insensitive"}- stmt := "SELECT COUNT(id) AS `matches`, COUNT(DISTINCT(root_id)) AS `docs` FROM `" + table + "` WHERE `" + table + "` MATCH '" + columnFilter() + ":(" + query + ")' AND type IN " + typeFilter- stmt += boxFilter + pathFilter+ 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 " + typeFilter+ stmt += boxFilter + pathFilterresult, _ := sql.Query(stmt)if 1 > len(result) {return@@ -735,8 +738,8 @@ func customIALFilter(query string) string {reg := strings.TrimPrefix(query, "\"")reg = strings.TrimSuffix(reg, "\"")reg = regexp.QuoteMeta(reg)- reg = "custom\\-.*" + reg + ".*"- return " AND ial REGEXP '" + reg + "'"+ reg = "custom-.*" + reg + ".*"+ return " OR ial REGEXP '" + reg + "'"}func markSearch(text string, keyword string, beforeLen int) (marked string, score float64) {@@ -903,9 +906,6 @@ func columnFilter() string {if Conf.Search.Memo {buf.WriteString(" memo")}- if Conf.Search.Custom {- buf.WriteString(" ial")- }buf.WriteString(" tag}")return buf.String()}