Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2023-02-15 15:25:41 +08:00
commit 68d1d066ea
9 changed files with 25 additions and 34 deletions

View file

@ -1,4 +1,5 @@
{
"allAttrs": "All attribute names and attribute values",
"chooseSyncDirection": "Choose sync direction",
"uploadData2Cloud": "⬆️ Upload data to cloud",
"uploadData2CloudTip": "Overwrite cloud data based on local data",

View file

@ -1,4 +1,5 @@
{
"allAttrs": "Todos los nombres de atributos y valores de atributos",
"chooseSyncDirection": "Elegir dirección de sincronización",
"uploadData2Cloud": "⬆️ Subir datos a la nube",
"uploadData2CloudTip": "Sobrescribir datos en la nube basados en datos locales",

View file

@ -1,4 +1,5 @@
{
"allAttrs": "Tous les noms d'attributs et les valeurs d'attributs",
"chooseSyncDirection": "Choisir la direction de synchronisation",
"uploadData2Cloud": "⬆️ Télécharger des données dans le cloud",
"uploadData2CloudTip": "Écraser les données cloud basées sur les données locales",

View file

@ -1,4 +1,5 @@
{
"allAttrs": "所有屬性名和屬性值",
"chooseSyncDirection": "選擇同步方向",
"uploadData2Cloud": "⬆️ 將數據上傳到雲端",
"uploadData2CloudTip": "以本地數據為準覆蓋雲端數據",

View file

@ -1,4 +1,5 @@
{
"allAttrs": "所有属性名和属性值",
"chooseSyncDirection": "选择同步方向",
"uploadData2Cloud": "⬆️ 将数据上传到云端",
"uploadData2CloudTip": "以本地数据为准覆盖云端数据",

View file

@ -148,10 +148,10 @@ export const query = {
</label>
<label class="fn__flex">
<div class="fn__flex-1">
${window.siyuan.languages.custom}
${window.siyuan.languages.allAttrs}
</div>
<span class="fn__space"></span>
<input class="b3-switch" id="custom" type="checkbox"${window.siyuan.config.search.custom ? " checked" : ""}/>
<input class="b3-switch" id="ial" type="checkbox"${window.siyuan.config.search.ial ? " checked" : ""}/>
</label>
</div>
</div>
@ -272,7 +272,7 @@ export const query = {
name: (query.element.querySelector("#name") as HTMLInputElement).checked,
alias: (query.element.querySelector("#alias") as HTMLInputElement).checked,
memo: (query.element.querySelector("#memo") as HTMLInputElement).checked,
custom: (query.element.querySelector("#custom") as HTMLInputElement).checked,
ial: (query.element.querySelector("#ial") as HTMLInputElement).checked,
limit: parseInt((query.element.querySelector("#limit") as HTMLInputElement).value),
caseSensitive: (query.element.querySelector("#caseSensitive") as HTMLInputElement).checked,
backlinkMentionName: (query.element.querySelector("#backlinkMentionName") as HTMLInputElement).checked,

View file

@ -466,7 +466,7 @@ declare interface IConfig {
name: boolean
alias: boolean
memo: boolean
custom: boolean
ial: boolean
limit: number
caseSensitive: boolean
backlinkMentionName: boolean

View file

@ -41,10 +41,10 @@ type Search struct {
Limit int `json:"limit"`
CaseSensitive bool `json:"caseSensitive"`
Name bool `json:"name"`
Alias bool `json:"alias"`
Memo bool `json:"memo"`
Custom bool `json:"custom"`
Name bool `json:"name"`
Alias bool `json:"alias"`
Memo bool `json:"memo"`
IAL bool `json:"ial"`
BacklinkMentionName bool `json:"backlinkMentionName"`
BacklinkMentionAlias bool `json:"backlinkMentionAlias"`
@ -77,10 +77,10 @@ func NewSearch() *Search {
Limit: 64,
CaseSensitive: true,
Name: true,
Alias: true,
Memo: true,
Custom: false,
Name: true,
Alias: true,
Memo: true,
IAL: false,
BacklinkMentionName: true,
BacklinkMentionAlias: false,

View file

@ -608,7 +608,7 @@ func fullTextSearchRefBlock(keyword string, beforeLen int) (ret []*Block) {
else 65535 end ASC, sort ASC, length ASC`
orderBy = strings.ReplaceAll(orderBy, "${keyword}", keyword)
stmt += orderBy + " LIMIT " + strconv.Itoa(Conf.Search.Limit)
blocks := sql.SelectBlocksRawStmt(stmt, Conf.Search.Limit)
blocks := sql.SelectBlocksRawStmtNoParse(stmt, Conf.Search.Limit)
ret = fromSQLBlocks(&blocks, "", beforeLen)
if 1 > len(ret) {
ret = []*Block{}
@ -644,7 +644,7 @@ func fullTextSearchByRegexp(exp, boxFilter, pathFilter, typeFilter, orderBy stri
stmt += boxFilter + pathFilter
stmt += " " + orderBy
stmt += " LIMIT " + strconv.Itoa(Conf.Search.Limit)
blocks := sql.SelectBlocksRawStmt(stmt, Conf.Search.Limit)
blocks := sql.SelectBlocksRawStmtNoParse(stmt, Conf.Search.Limit)
ret = fromSQLBlocks(&blocks, "", beforeLen)
if 1 > len(ret) {
ret = []*Block{}
@ -681,9 +681,9 @@ func fullTextSearchByFTS(query, boxFilter, pathFilter, typeFilter, orderBy strin
"tag, " +
"highlight(" + table + ", 11, '" + search.SearchMarkLeft + "', '" + search.SearchMarkRight + "') AS content, " +
"fcontent, markdown, length, type, subtype, ial, sort, created, updated"
stmt := "SELECT " + projections + " FROM " + table + " WHERE " + table + " MATCH '" + columnFilter() + ":(" + query + ")' AND type IN " + typeFilter
stmt := "SELECT " + projections + " FROM " + table + " WHERE (`" + table + "` MATCH '" + columnFilter() + ":(" + query + ")'"
stmt += ") AND type IN " + typeFilter
stmt += boxFilter + pathFilter
stmt += customIALFilter(query)
stmt += " " + orderBy
stmt += " LIMIT " + strconv.Itoa(Conf.Search.Limit)
blocks := sql.SelectBlocksRawStmt(stmt, Conf.Search.Limit)
@ -713,9 +713,9 @@ func fullTextSearchCount(query, boxFilter, pathFilter, typeFilter string) (match
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 " + typeFilter
stmt := "SELECT COUNT(id) AS `matches`, COUNT(DISTINCT(root_id)) AS `docs` FROM `" + table + "` WHERE (`" + table + "` MATCH '" + columnFilter() + ":(" + query + ")'"
stmt += ") AND type IN " + typeFilter
stmt += boxFilter + pathFilter
stmt += customIALFilter(query)
result, _ := sql.Query(stmt)
if 1 > len(result) {
return
@ -725,20 +725,6 @@ func fullTextSearchCount(query, boxFilter, pathFilter, typeFilter string) (match
return
}
// customIALFilter 用于组装自定义属性过滤条件。
// 打开自定义属性搜索选项后出现多余搜索结果 https://github.com/siyuan-note/siyuan/issues/7367
func customIALFilter(query string) string {
if !Conf.Search.Custom {
return ""
}
reg := strings.TrimPrefix(query, "\"")
reg = strings.TrimSuffix(reg, "\"")
reg = regexp.QuoteMeta(reg)
reg = "custom\\-.*" + reg + ".*"
return " AND ial REGEXP '" + reg + "'"
}
func markSearch(text string, keyword string, beforeLen int) (marked string, score float64) {
if 0 == len(keyword) {
marked = text
@ -880,7 +866,7 @@ func fieldRegexp(regexp string) string {
buf.WriteString(regexp)
buf.WriteString("'")
}
if Conf.Search.Custom {
if Conf.Search.IAL {
buf.WriteString(" OR ial REGEXP '")
buf.WriteString(regexp)
buf.WriteString("'")
@ -903,7 +889,7 @@ func columnFilter() string {
if Conf.Search.Memo {
buf.WriteString(" memo")
}
if Conf.Search.Custom {
if Conf.Search.IAL {
buf.WriteString(" ial")
}
buf.WriteString(" tag}")