|
@@ -476,7 +476,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
|
|
|
|
|
if 1 > len(ids) {
|
|
|
// `Replace All` is no longer affected by pagination https://github.com/siyuan-note/siyuan/issues/8265
|
|
|
- blocks, _, _, _ := FullTextSearchBlock(keyword, boxes, paths, types, method, orderBy, groupBy, 1, math.MaxInt)
|
|
|
+ blocks, _, _, _, _ := FullTextSearchBlock(keyword, boxes, paths, types, method, orderBy, groupBy, 1, math.MaxInt)
|
|
|
for _, block := range blocks {
|
|
|
ids = append(ids, block.ID)
|
|
|
}
|
|
@@ -903,7 +903,7 @@ func replaceNodeTokens(n *ast.Node, method int, keyword string, replacement stri
|
|
|
// method:0:关键字,1:查询语法,2:SQL,3:正则表达式
|
|
|
// orderBy: 0:按块类型(默认),1:按创建时间升序,2:按创建时间降序,3:按更新时间升序,4:按更新时间降序,5:按内容顺序(仅在按文档分组时),6:按相关度升序,7:按相关度降序
|
|
|
// groupBy:0:不分组,1:按文档分组
|
|
|
-func FullTextSearchBlock(query string, boxes, paths []string, types map[string]bool, method, orderBy, groupBy, page, pageSize int) (ret []*Block, matchedBlockCount, matchedRootCount, pageCount int) {
|
|
|
+func FullTextSearchBlock(query string, boxes, paths []string, types map[string]bool, method, orderBy, groupBy, page, pageSize int) (ret []*Block, matchedBlockCount, matchedRootCount, pageCount int, docMode bool) {
|
|
|
ret = []*Block{}
|
|
|
if "" == query {
|
|
|
return
|
|
@@ -945,7 +945,12 @@ func FullTextSearchBlock(query string, boxes, paths []string, types map[string]b
|
|
|
typeFilter := buildTypeFilter(types)
|
|
|
boxFilter := buildBoxesFilter(boxes)
|
|
|
pathFilter := buildPathsFilter(paths)
|
|
|
- blocks, matchedBlockCount, matchedRootCount = fullTextSearchByKeyword(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderByClause, beforeLen, page, pageSize)
|
|
|
+ if 2 > len(strings.Split(query, " ")) {
|
|
|
+ blocks, matchedBlockCount, matchedRootCount = fullTextSearchByQuerySyntax(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderByClause, beforeLen, page, pageSize)
|
|
|
+ } else {
|
|
|
+ docMode = true // 文档全文搜索模式 https://github.com/siyuan-note/siyuan/issues/10584
|
|
|
+ blocks, matchedBlockCount, matchedRootCount = fullTextSearchByKeyword(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderByClause, beforeLen, page, pageSize)
|
|
|
+ }
|
|
|
}
|
|
|
pageCount = (matchedBlockCount + pageSize - 1) / pageSize
|
|
|
|
|
@@ -1290,10 +1295,6 @@ func fullTextSearchByKeyword(query, boxFilter, pathFilter, typeFilter, ignoreFil
|
|
|
ret, matchedBlockCount, matchedRootCount = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+query+"'", beforeLen, page, pageSize)
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- if 2 > len(strings.Split(query, " ")) {
|
|
|
- return fullTextSearchByFTS(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderBy, beforeLen, page, pageSize)
|
|
|
- }
|
|
|
return fullTextSearchByFTSWithRoot(query, boxFilter, pathFilter, typeFilter, ignoreFilter, orderBy, beforeLen, page, pageSize)
|
|
|
}
|
|
|
|