🎨 在 设置 - 搜索 中分别增加虚拟引用和反链提及 最大关键字数量限制 https://github.com/siyuan-note/siyuan/issues/6603

This commit is contained in:
Liang Ding 2022-11-16 16:22:34 +08:00
parent 1bb3870243
commit 87fde9a1e8
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
9 changed files with 19 additions and 9 deletions

View file

@ -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",

View file

@ -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",

View file

@ -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é",

View file

@ -864,7 +864,7 @@
"35": "正在重建索引,請稍等...",
"36": "歷史文檔內容太多,為了不影響性能,已經切換為純文本顯示",
"37": "雲端同步目錄的名稱請勿包含空格和特殊符號",
"38": "提及關鍵字數量 [%d] 過多,目前最多僅支援搜索 [512] 個關鍵字",
"38": "提及關鍵字數量 [%d] 過多,如有需要可以調整 [設置 - 搜索 - 反鏈提及 - 關鍵字數量限制]",
"39": "正在刪除索引 %s",
"40": "正在插入索引 %s",
"41": "上傳完畢",

View file

@ -864,7 +864,7 @@
"35": "正在重建索引,请稍等...",
"36": "历史文档内容太多,为了不影响性能,已经切换为纯文本显示",
"37": "云端同步目录的名称请勿包含空格和特殊符号",
"38": "提及关键字数量 [%d] 过多,目前最多仅支持搜索 [512] 个关键字",
"38": "提及关键字数量 [%d] 过多,如有需要可以调整 [设置 - 搜索 - 反链提及 - 关键字数量限制]",
"39": "正在删除索引 %s",
"40": "正在插入索引 %s",
"41": "上传完毕",

View file

@ -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,
}
}

View file

@ -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 + "\"")

View file

@ -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()

View file

@ -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
}