Skip to content

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

:art: Improve `Add to Database` search https://github.com/siyuan-note/siyuan/issues/11644

Daniel06b7c7e3db9f
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index e16ee3ffd2..bf1f0673c2 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -317,6 +317,7 @@ func SearchAttributeView(keyword string, excludeAvIDs []string) (ret []*SearchAt
ret = []*SearchAttributeViewResult{}
keyword = strings.TrimSpace(keyword)
+ keywords := strings.Fields(keyword)
type result struct {
AvID string
@@ -349,8 +350,19 @@ func SearchAttributeView(keyword string, excludeAvIDs []string) (ret []*SearchAt
name, _ := av.GetAttributeViewNameByPath(filepath.Join(avDir, entry.Name()))
info, _ := entry.Info()
if "" != keyword {
- if strings.Contains(strings.ToLower(name), strings.ToLower(keyword)) {
- score := smetrics.JaroWinkler(name, keyword, 0.7, 4)
+ score := 0.0
+ hit := false
+ for _, k := range keywords {
+ if strings.Contains(strings.ToLower(name), strings.ToLower(k)) {
+ score += smetrics.JaroWinkler(name, k, 0.7, 4)
+ hit = true
+ } else {
+ hit = false
+ break
+ }
+ }
+
+ if hit {
a := &result{AvID: id, AvName: name, Score: score}
if nil != info && !info.ModTime().IsZero() {
a.AvUpdated = info.ModTime().UnixMilli()