mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Tag search supports space-separated keywords https://github.com/siyuan-note/siyuan/issues/14580
This commit is contained in:
parent
8a5dafeb07
commit
da9caf91cf
1 changed files with 10 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue