mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 07:30:12 +01:00
🎨 Improve Add to Database search https://github.com/siyuan-note/siyuan/issues/11644
This commit is contained in:
parent
427b8b7ef4
commit
06b7c7e3db
1 changed files with 14 additions and 2 deletions
|
|
@ -317,6 +317,7 @@ func SearchAttributeView(keyword string, excludeAvIDs []string) (ret []*SearchAt
|
||||||
|
|
||||||
ret = []*SearchAttributeViewResult{}
|
ret = []*SearchAttributeViewResult{}
|
||||||
keyword = strings.TrimSpace(keyword)
|
keyword = strings.TrimSpace(keyword)
|
||||||
|
keywords := strings.Fields(keyword)
|
||||||
|
|
||||||
type result struct {
|
type result struct {
|
||||||
AvID string
|
AvID string
|
||||||
|
|
@ -349,8 +350,19 @@ func SearchAttributeView(keyword string, excludeAvIDs []string) (ret []*SearchAt
|
||||||
name, _ := av.GetAttributeViewNameByPath(filepath.Join(avDir, entry.Name()))
|
name, _ := av.GetAttributeViewNameByPath(filepath.Join(avDir, entry.Name()))
|
||||||
info, _ := entry.Info()
|
info, _ := entry.Info()
|
||||||
if "" != keyword {
|
if "" != keyword {
|
||||||
if strings.Contains(strings.ToLower(name), strings.ToLower(keyword)) {
|
score := 0.0
|
||||||
score := smetrics.JaroWinkler(name, keyword, 0.7, 4)
|
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}
|
a := &result{AvID: id, AvName: name, Score: score}
|
||||||
if nil != info && !info.ModTime().IsZero() {
|
if nil != info && !info.ModTime().IsZero() {
|
||||||
a.AvUpdated = info.ModTime().UnixMilli()
|
a.AvUpdated = info.ModTime().UnixMilli()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue