Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: 在提及中搜索不到结果问题 Fix https://github.com/siyuan-note/siyuan/issues/5236

Liang Ding9e886910df2b
diff --git a/kernel/model/backlink.go b/kernel/model/backlink.go
index 36fd39a0cb..d1782b3260 100644
--- a/kernel/model/backlink.go
+++ b/kernel/model/backlink.go
@@ -358,19 +358,23 @@ func searchBackmention(mentionKeywords []string, keyword string, excludeBacklink
buf.WriteString(" OR ")
}
}
- buf.WriteString(")'")
+ buf.WriteString(")")
if "" != keyword {
- buf.WriteString(" AND MATCH '{content}:'")
- buf.WriteString("\"" + keyword + "\"")
keyword = strings.ReplaceAll(keyword, "\"", "\"\"")
+ buf.WriteString(" AND (\"" + keyword + "\")")
}
+ buf.WriteString("'")
buf.WriteString(" AND root_id != '" + rootID + "'") // 不在定义块所在文档中搜索
buf.WriteString(" AND type IN ('d', 'h', 'p', 't')")
buf.WriteString(" ORDER BY id DESC LIMIT " + strconv.Itoa(Conf.Search.Limit))
query := buf.String()
sqlBlocks := sql.SelectBlocksRawStmt(query, Conf.Search.Limit)
- blocks := fromSQLBlocks(&sqlBlocks, strings.Join(mentionKeywords, search.TermSep), beforeLen)
+ terms := mentionKeywords
+ if "" != keyword {
+ terms = append(terms, keyword)
+ }
+ blocks := fromSQLBlocks(&sqlBlocks, strings.Join(terms, search.TermSep), beforeLen)
// 排除链接文本 https://github.com/siyuan-note/siyuan/issues/1542
luteEngine := NewLute()