Skip to content

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

:bug: 搜索设置忽略大小写时结果统计不正确 Fix https://github.com/siyuan-note/siyuan/issues/6664

Liang Ding4650eec7c642
diff --git a/kernel/model/search.go b/kernel/model/search.go
index ff93044aa1..070ba0eace 100644
--- a/kernel/model/search.go
+++ b/kernel/model/search.go
@@ -378,7 +378,12 @@ func fullTextSearchCount(query, box, path, filter string) (matchedBlockCount, ma
return
}
- stmt := "SELECT COUNT(id) AS `matches`, COUNT(DISTINCT(root_id)) AS `docs` FROM `blocks_fts` WHERE `blocks_fts` MATCH '" + columnFilter() + ":(" + query + ")' AND type IN " + filter
+ table := "blocks_fts" // 大小写敏感
+ if !Conf.Search.CaseSensitive {
+ table = "blocks_fts_case_insensitive"
+ }
+
+ stmt := "SELECT COUNT(id) AS `matches`, COUNT(DISTINCT(root_id)) AS `docs` FROM `" + table + "` WHERE `" + table + "` MATCH '" + columnFilter() + ":(" + query + ")' AND type IN " + filter
if "" != box {
stmt += " AND box = '" + box + "'"
}