Skip to content

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

:art: Tag search supports space-separated keywords https://github.com/siyuan-note/siyuan/issues/14580

Danielda9caf91cf32
diff --git a/kernel/sql/span.go b/kernel/sql/span.go
index 773a8494dd..d0b055cbb0 100644
--- a/kernel/sql/span.go
+++ b/kernel/sql/span.go
@@ -96,8 +96,16 @@ func QueryTagSpansByLabel(label string) (ret []*Span) {
}
func QueryTagSpansByKeyword(keyword string, limit int) (ret []*Span) {
- stmt := "SELECT * FROM spans WHERE type LIKE '%tag%' AND content LIKE '%" + keyword + "%' GROUP BY markdown"
- stmt += " LIMIT " + strconv.Itoa(limit)
+ // 标签搜索支持空格分隔关键字 Tag search supports space-separated keywords https://github.com/siyuan-note/siyuan/issues/14580
+ keywords := strings.Split(keyword, " ")
+ contentLikes := ""
+ for _, k := range keywords {
+ if contentLikes != "" {
+ contentLikes += " OR "
+ }
+ contentLikes += "content LIKE '%" + k + "%'"
+ }
+ stmt := "SELECT * FROM spans WHERE type LIKE '%tag%' AND (" + contentLikes + ") GROUP BY markdown LIMIT " + strconv.Itoa(limit)
rows, err := query(stmt)
if err != nil {
logging.LogErrorf("sql query failed: %s", err)