alist-org / alist

🗂️A file list/WebDAV program that supports multiple storages, powered by Gin and Solidjs. / 一个支持多存储的文件列表/WebDAV程序,使用 Gin 和 Solidjs。
https://alist.nn.ci
GNU Affero General Public License v3.0
39.38k stars 5.11k forks source link

建议增加索引避免关键字功能 #6564

Open duckeaty opened 4 weeks ago

duckeaty commented 4 weeks ago

Please make sure of the following things

Description of the feature / 需求描述

在群晖上挂载本地盘发现会出现@eaDir,设置为隐藏后任然能搜索出来。能不能增加一个关键字框,对期内的关键字避免索引,可以在数据库增加触发器来完成。

Suggested solution / 实现思路

以屏闭@eaDir为例:

基本不影响索引建立速度,其实测效果非常好,可以完全避免@eadir进索引,方法如下: 在数据库的x_search_nodes表增加触发器,在insert前对比关键字并阻止入库:

DELIMITER //
CREATE TRIGGER trg_before_insert_check
BEFORE INSERT ON x_search_nodes
FOR EACH ROW
BEGIN
    IF LOCATE('@eaDir', NEW.name) > 0 OR LOCATE('@eaDir', NEW.parent) > 0 THEN
        SIGNAL SQLSTATE '45000'
        SET MESSAGE_TEXT = 'Insert is not allowed for names or parent containing "@eaDir"';
    END IF;
END;
//
DELIMITER ;

Additional context / 附件

https://github.com/alist-org/alist/discussions/6563alist在挂载群晖时显示@eaDir及索引后搜索会出现@eaDir的解决方法,附改MYSQL后搜索慢的解决方法

welcome[bot] commented 4 weeks ago

Thanks for opening your first issue here! Be sure to follow the issue template!