From 87fde9a1e87c9f5d428d358517b10cc027b971fa Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 16 Nov 2022 16:22:34 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E5=9C=A8=20=E8=AE=BE=E7=BD=AE=20-=20?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=20=E4=B8=AD=E5=88=86=E5=88=AB=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=99=9A=E6=8B=9F=E5=BC=95=E7=94=A8=E5=92=8C=E5=8F=8D?= =?UTF-8?q?=E9=93=BE=E6=8F=90=E5=8F=8A=20`=E6=9C=80=E5=A4=A7=E5=85=B3?= =?UTF-8?q?=E9=94=AE=E5=AD=97=E6=95=B0=E9=87=8F=E9=99=90=E5=88=B6`=20https?= =?UTF-8?q?://github.com/siyuan-note/siyuan/issues/6603?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/appearance/langs/en_US.json | 2 +- app/appearance/langs/es_ES.json | 2 +- app/appearance/langs/fr_FR.json | 2 +- app/appearance/langs/zh_CHT.json | 2 +- app/appearance/langs/zh_CN.json | 2 +- kernel/conf/search.go | 4 ++++ kernel/model/backlink.go | 2 +- kernel/model/conf.go | 6 ++++++ kernel/model/virutalref.go | 6 +++--- 9 files changed, 19 insertions(+), 9 deletions(-) diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index af6a9c1c3..2af5c263b 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -864,7 +864,7 @@ "35": "Rebuilding index, please wait...", "36": "There is too much content in the historical document, in order not to affect performance, it has been switched to plain text display", "37": "Do not include spaces and special symbols in the name of the cloud sync directory", - "38": "The number of mentioned keywords [%d] is too many, currently only supports up to [512] keywords", + "38": "Too many keywords mentioned [%d], adjust if necessary [Settings - Search - Backlink Mentions - Keyword Limit]", "39": "Deleting index %s", "40": "Inserting index %s", "41": "Upload completed", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index a4d82cfb7..f2c62fccc 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -864,7 +864,7 @@ "35": "Reconstruyendo el índice, por favor espere...", "36": "Hay demasiado contenido en el documento historico, para no afectar el rendimiento, se ha cambiado a visualizacion de texto sin formato", "37": "No incluyas espacios ni símbolos especiales en el nombre del directorio de sincronización con la nube", - "38": "El número de palabras clave mencionadas [%d] son demasiados, actualmente solo admite hasta [512] palabras clave", + "38": "Demasiadas palabras clave mencionadas [%d], ajústelas si es necesario [Configuración - Búsqueda - Menciones de backlinks - Límite de palabras clave]", "39": "Eliminando índice %s", "40": "Insertando índice %s", "41": "Carga completada", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index 778429ea3..ab4fad965 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -864,7 +864,7 @@ "35": "Recréation de l'index, veuillez patienter...", "36": "Il y a trop de contenu dans le document historique, afin de ne pas affecter les performances, il a été basculé sur l'affichage en texte brut", "37": "N'incluez pas d'espaces et de symboles spéciaux dans le nom du répertoire de synchronisation cloud", - "38": "Le nombre de mots-clés mentionnés [%d] est trop élevé, ne prend actuellement en charge que jusqu'à [512] mots-clés", + "38": "Trop de mots-clés mentionnés [%d], ajustez si nécessaire [Paramètres - Recherche - Mentions de backlink - Limite de mots-clés]", "39": "Suppression de l'index %s", "40": "Insertion de l'index %s", "41": "Transfert complété", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index 9f7961088..eb234e307 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -864,7 +864,7 @@ "35": "正在重建索引,請稍等...", "36": "歷史文檔內容太多,為了不影響性能,已經切換為純文本顯示", "37": "雲端同步目錄的名稱請勿包含空格和特殊符號", - "38": "提及關鍵字數量 [%d] 過多,目前最多僅支援搜索 [512] 個關鍵字", + "38": "提及關鍵字數量 [%d] 過多,如有需要可以調整 [設置 - 搜索 - 反鏈提及 - 關鍵字數量限制]", "39": "正在刪除索引 %s", "40": "正在插入索引 %s", "41": "上傳完畢", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index 9f7e30bd1..cd6e26e82 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -864,7 +864,7 @@ "35": "正在重建索引,请稍等...", "36": "历史文档内容太多,为了不影响性能,已经切换为纯文本显示", "37": "云端同步目录的名称请勿包含空格和特殊符号", - "38": "提及关键字数量 [%d] 过多,目前最多仅支持搜索 [512] 个关键字", + "38": "提及关键字数量 [%d] 过多,如有需要可以调整 [设置 - 搜索 - 反链提及 - 关键字数量限制]", "39": "正在删除索引 %s", "40": "正在插入索引 %s", "41": "上传完毕", diff --git a/kernel/conf/search.go b/kernel/conf/search.go index c85d368fa..a9e1cf740 100644 --- a/kernel/conf/search.go +++ b/kernel/conf/search.go @@ -49,11 +49,13 @@ type Search struct { BacklinkMentionAlias bool `json:"backlinkMentionAlias"` BacklinkMentionAnchor bool `json:"backlinkMentionAnchor"` BacklinkMentionDoc bool `json:"backlinkMentionDoc"` + BacklinkMentionLimit int `json:"backlinkMentionLimit"` VirtualRefName bool `json:"virtualRefName"` VirtualRefAlias bool `json:"virtualRefAlias"` VirtualRefAnchor bool `json:"virtualRefAnchor"` VirtualRefDoc bool `json:"virtualRefDoc"` + VirtualRefLimit int `json:"virtualRefLimit"` } func NewSearch() *Search { @@ -82,11 +84,13 @@ func NewSearch() *Search { BacklinkMentionAlias: false, BacklinkMentionAnchor: true, BacklinkMentionDoc: true, + BacklinkMentionLimit: 512, VirtualRefName: true, VirtualRefAlias: false, VirtualRefAnchor: true, VirtualRefDoc: true, + VirtualRefLimit: 512, } } diff --git a/kernel/model/backlink.go b/kernel/model/backlink.go index 66da9cc01..372c3d817 100644 --- a/kernel/model/backlink.go +++ b/kernel/model/backlink.go @@ -737,7 +737,7 @@ func searchBackmention(mentionKeywords []string, keyword string, excludeBacklink buf := bytes.Buffer{} buf.WriteString("SELECT * FROM " + table + " WHERE " + table + " MATCH '{content}:(") for i, mentionKeyword := range mentionKeywords { - if 511 < i { // 提及搜索最大限制 https://github.com/siyuan-note/siyuan/issues/3715 + if Conf.Search.BacklinkMentionLimit < i { util.PushMsg(fmt.Sprintf(Conf.Language(38), len(mentionKeywords)), 5000) mentionKeyword = strings.ReplaceAll(mentionKeyword, "\"", "\"\"") buf.WriteString("\"" + mentionKeyword + "\"") diff --git a/kernel/model/conf.go b/kernel/model/conf.go index 52c5b9af1..2576ca6ca 100644 --- a/kernel/model/conf.go +++ b/kernel/model/conf.go @@ -278,6 +278,12 @@ func InitConf() { if 1 > Conf.Search.Limit { Conf.Search.Limit = 64 } + if 1 > Conf.Search.BacklinkMentionLimit { + Conf.Search.BacklinkMentionLimit = 512 + } + if 1 > Conf.Search.VirtualRefLimit { + Conf.Search.VirtualRefLimit = 512 + } if nil == Conf.Stat { Conf.Stat = conf.NewStat() diff --git a/kernel/model/virutalref.go b/kernel/model/virutalref.go index 0e7614955..4fa5173d0 100644 --- a/kernel/model/virutalref.go +++ b/kernel/model/virutalref.go @@ -109,9 +109,9 @@ func getVirtualRefKeywords(docName string) (ret []string) { // 虚拟引用排除当前文档名 https://github.com/siyuan-note/siyuan/issues/4537 ret = gulu.Str.ExcludeElem(ret, []string{docName}) ret = prepareMarkKeywords(ret) - // 虚拟引用搜索关键字最多支持 `搜索结果显示数` 的 8 倍 https://github.com/siyuan-note/siyuan/issues/6603 - if Conf.Search.Limit*8 < len(ret) { - ret = ret[:Conf.Search.Limit*8] + + if Conf.Search.VirtualRefLimit < len(ret) { + ret = ret[:Conf.Search.VirtualRefLimit] } return }