|
@@ -409,7 +409,7 @@ func FullTextSearchBlock(query string, boxes, paths []string, types map[string]b
|
|
pathFilter := buildPathsFilter(paths)
|
|
pathFilter := buildPathsFilter(paths)
|
|
blocks, matchedBlockCount, matchedRootCount = fullTextSearchByQuerySyntax(query, boxFilter, pathFilter, filter, orderByClause, beforeLen, page)
|
|
blocks, matchedBlockCount, matchedRootCount = fullTextSearchByQuerySyntax(query, boxFilter, pathFilter, filter, orderByClause, beforeLen, page)
|
|
case 2: // SQL
|
|
case 2: // SQL
|
|
- blocks, matchedBlockCount, matchedRootCount = searchBySQL(query, beforeLen)
|
|
|
|
|
|
+ blocks, matchedBlockCount, matchedRootCount = searchBySQL(query, beforeLen, page)
|
|
case 3: // 正则表达式
|
|
case 3: // 正则表达式
|
|
typeFilter := buildTypeFilter(types)
|
|
typeFilter := buildTypeFilter(types)
|
|
boxFilter := buildBoxesFilter(boxes)
|
|
boxFilter := buildBoxesFilter(boxes)
|
|
@@ -600,10 +600,10 @@ func buildTypeFilter(types map[string]bool) string {
|
|
return s.TypeFilter()
|
|
return s.TypeFilter()
|
|
}
|
|
}
|
|
|
|
|
|
-func searchBySQL(stmt string, beforeLen int) (ret []*Block, matchedBlockCount, matchedRootCount int) {
|
|
|
|
|
|
+func searchBySQL(stmt string, beforeLen, page int) (ret []*Block, matchedBlockCount, matchedRootCount int) {
|
|
stmt = gulu.Str.RemoveInvisible(stmt)
|
|
stmt = gulu.Str.RemoveInvisible(stmt)
|
|
stmt = strings.TrimSpace(stmt)
|
|
stmt = strings.TrimSpace(stmt)
|
|
- blocks := sql.SelectBlocksRawStmt(stmt, Conf.Search.Limit)
|
|
|
|
|
|
+ blocks := sql.SelectBlocksRawStmt(stmt, page, Conf.Search.Limit)
|
|
ret = fromSQLBlocks(&blocks, "", beforeLen)
|
|
ret = fromSQLBlocks(&blocks, "", beforeLen)
|
|
if 1 > len(ret) {
|
|
if 1 > len(ret) {
|
|
ret = []*Block{}
|
|
ret = []*Block{}
|
|
@@ -630,7 +630,7 @@ func fullTextSearchRefBlock(keyword string, beforeLen int, onlyDoc bool) (ret []
|
|
keyword = gulu.Str.RemoveInvisible(keyword)
|
|
keyword = gulu.Str.RemoveInvisible(keyword)
|
|
|
|
|
|
if ast.IsNodeIDPattern(keyword) {
|
|
if ast.IsNodeIDPattern(keyword) {
|
|
- ret, _, _ = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+keyword+"'", 36)
|
|
|
|
|
|
+ ret, _, _ = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+keyword+"'", 36, 1)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -682,7 +682,7 @@ func fullTextSearchRefBlock(keyword string, beforeLen int, onlyDoc bool) (ret []
|
|
func fullTextSearchByQuerySyntax(query, boxFilter, pathFilter, typeFilter, orderBy string, beforeLen, page int) (ret []*Block, matchedBlockCount, matchedRootCount int) {
|
|
func fullTextSearchByQuerySyntax(query, boxFilter, pathFilter, typeFilter, orderBy string, beforeLen, page int) (ret []*Block, matchedBlockCount, matchedRootCount int) {
|
|
query = gulu.Str.RemoveInvisible(query)
|
|
query = gulu.Str.RemoveInvisible(query)
|
|
if ast.IsNodeIDPattern(query) {
|
|
if ast.IsNodeIDPattern(query) {
|
|
- ret, matchedBlockCount, matchedRootCount = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+query+"'", beforeLen)
|
|
|
|
|
|
+ ret, matchedBlockCount, matchedRootCount = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+query+"'", beforeLen, page)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
return fullTextSearchByFTS(query, boxFilter, pathFilter, typeFilter, orderBy, beforeLen, page)
|
|
return fullTextSearchByFTS(query, boxFilter, pathFilter, typeFilter, orderBy, beforeLen, page)
|
|
@@ -691,7 +691,7 @@ func fullTextSearchByQuerySyntax(query, boxFilter, pathFilter, typeFilter, order
|
|
func fullTextSearchByKeyword(query, boxFilter, pathFilter, typeFilter string, orderBy string, beforeLen, page int) (ret []*Block, matchedBlockCount, matchedRootCount int) {
|
|
func fullTextSearchByKeyword(query, boxFilter, pathFilter, typeFilter string, orderBy string, beforeLen, page int) (ret []*Block, matchedBlockCount, matchedRootCount int) {
|
|
query = gulu.Str.RemoveInvisible(query)
|
|
query = gulu.Str.RemoveInvisible(query)
|
|
if ast.IsNodeIDPattern(query) {
|
|
if ast.IsNodeIDPattern(query) {
|
|
- ret, matchedBlockCount, matchedRootCount = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+query+"'", beforeLen)
|
|
|
|
|
|
+ ret, matchedBlockCount, matchedRootCount = searchBySQL("SELECT * FROM `blocks` WHERE `id` = '"+query+"'", beforeLen, page)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
query = stringQuery(query)
|
|
query = stringQuery(query)
|
|
@@ -747,7 +747,7 @@ func fullTextSearchByFTS(query, boxFilter, pathFilter, typeFilter, orderBy strin
|
|
stmt += boxFilter + pathFilter
|
|
stmt += boxFilter + pathFilter
|
|
stmt += " " + orderBy
|
|
stmt += " " + orderBy
|
|
stmt += " LIMIT " + strconv.Itoa(pageSize) + " OFFSET " + strconv.Itoa((page-1)*pageSize)
|
|
stmt += " LIMIT " + strconv.Itoa(pageSize) + " OFFSET " + strconv.Itoa((page-1)*pageSize)
|
|
- blocks := sql.SelectBlocksRawStmt(stmt, Conf.Search.Limit)
|
|
|
|
|
|
+ blocks := sql.SelectBlocksRawStmt(stmt, page, Conf.Search.Limit)
|
|
ret = fromSQLBlocks(&blocks, "", beforeLen)
|
|
ret = fromSQLBlocks(&blocks, "", beforeLen)
|
|
if 1 > len(ret) {
|
|
if 1 > len(ret) {
|
|
ret = []*Block{}
|
|
ret = []*Block{}
|