mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-19 10:30:45 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
2aa66a5d29
@ -1016,7 +1016,11 @@ func FullTextSearchBlock(query string, boxes, paths []string, types map[string]b
|
|||||||
typeFilter := buildTypeFilter(types)
|
typeFilter := buildTypeFilter(types)
|
||||||
boxFilter := buildBoxesFilter(boxes)
|
boxFilter := buildBoxesFilter(boxes)
|
||||||
pathFilter := buildPathsFilter(paths)
|
pathFilter := buildPathsFilter(paths)
|
||||||
blocks, matchedBlockCount, matchedRootCount = fullTextSearchByQuerySyntax(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderByClause, beforeLen, page, pageSize)
|
if ast.IsNodeIDPattern(query) {
|
||||||
|
blocks, matchedBlockCount, matchedRootCount = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+query+"'", beforeLen, page, pageSize)
|
||||||
|
} else {
|
||||||
|
blocks, matchedBlockCount, matchedRootCount = fullTextSearchByFTS(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderByClause, beforeLen, page, pageSize)
|
||||||
|
}
|
||||||
case 2: // SQL
|
case 2: // SQL
|
||||||
blocks, matchedBlockCount, matchedRootCount = searchBySQL(query, beforeLen, page, pageSize)
|
blocks, matchedBlockCount, matchedRootCount = searchBySQL(query, beforeLen, page, pageSize)
|
||||||
case 3: // 正则表达式
|
case 3: // 正则表达式
|
||||||
@ -1028,12 +1032,16 @@ func FullTextSearchBlock(query string, boxes, paths []string, types map[string]b
|
|||||||
typeFilter := buildTypeFilter(types)
|
typeFilter := buildTypeFilter(types)
|
||||||
boxFilter := buildBoxesFilter(boxes)
|
boxFilter := buildBoxesFilter(boxes)
|
||||||
pathFilter := buildPathsFilter(paths)
|
pathFilter := buildPathsFilter(paths)
|
||||||
|
if ast.IsNodeIDPattern(query) {
|
||||||
|
blocks, matchedBlockCount, matchedRootCount = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+query+"'", beforeLen, page, pageSize)
|
||||||
|
} else {
|
||||||
if 2 > len(strings.Split(strings.TrimSpace(query), " ")) {
|
if 2 > len(strings.Split(strings.TrimSpace(query), " ")) {
|
||||||
query = stringQuery(query)
|
query = stringQuery(query)
|
||||||
blocks, matchedBlockCount, matchedRootCount = fullTextSearchByQuerySyntax(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderByClause, beforeLen, page, pageSize)
|
blocks, matchedBlockCount, matchedRootCount = fullTextSearchByFTS(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderByClause, beforeLen, page, pageSize)
|
||||||
} else {
|
} else {
|
||||||
docMode = true // 文档全文搜索模式 https://github.com/siyuan-note/siyuan/issues/10584
|
docMode = true // 文档全文搜索模式 https://github.com/siyuan-note/siyuan/issues/10584
|
||||||
blocks, matchedBlockCount, matchedRootCount = fullTextSearchByKeyword(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderByClause, beforeLen, page, pageSize)
|
blocks, matchedBlockCount, matchedRootCount = fullTextSearchByLikeWithRoot(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderByClause, beforeLen, page, pageSize)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pageCount = (matchedBlockCount + pageSize - 1) / pageSize
|
pageCount = (matchedBlockCount + pageSize - 1) / pageSize
|
||||||
@ -1367,22 +1375,6 @@ func extractID(content string) (ret string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func fullTextSearchByQuerySyntax(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderBy string, beforeLen, page, pageSize int) (ret []*Block, matchedBlockCount, matchedRootCount int) {
|
|
||||||
if ast.IsNodeIDPattern(query) {
|
|
||||||
ret, matchedBlockCount, matchedRootCount = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+query+"'", beforeLen, page, pageSize)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return fullTextSearchByFTS(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderBy, beforeLen, page, pageSize)
|
|
||||||
}
|
|
||||||
|
|
||||||
func fullTextSearchByKeyword(query, boxFilter, pathFilter, typeFilter, ignoreFilter string, orderBy string, beforeLen, page, pageSize int) (ret []*Block, matchedBlockCount, matchedRootCount int) {
|
|
||||||
if ast.IsNodeIDPattern(query) {
|
|
||||||
ret, matchedBlockCount, matchedRootCount = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+query+"'", beforeLen, page, pageSize)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return fullTextSearchByLikeWithRoot(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderBy, beforeLen, page, pageSize)
|
|
||||||
}
|
|
||||||
|
|
||||||
func fullTextSearchByRegexp(exp, boxFilter, pathFilter, typeFilter, ignoreFilter, orderBy string, beforeLen, page, pageSize int) (ret []*Block, matchedBlockCount, matchedRootCount int) {
|
func fullTextSearchByRegexp(exp, boxFilter, pathFilter, typeFilter, ignoreFilter, orderBy string, beforeLen, page, pageSize int) (ret []*Block, matchedBlockCount, matchedRootCount int) {
|
||||||
fieldFilter := fieldRegexp(exp)
|
fieldFilter := fieldRegexp(exp)
|
||||||
stmt := "SELECT * FROM `blocks` WHERE " + fieldFilter + " AND type IN " + typeFilter
|
stmt := "SELECT * FROM `blocks` WHERE " + fieldFilter + " AND type IN " + typeFilter
|
||||||
|
Loading…
Reference in New Issue
Block a user