mirror of
https://github.com/gotoeasy/glogcenter.git
synced 2025-09-15 12:58:34 +08:00
检索结果后处理
This commit is contained in:
parent
286be910e1
commit
cf32fe9ce5
@ -2,7 +2,6 @@ package ldb
|
||||
|
||||
import (
|
||||
"glc/com"
|
||||
"glc/conf"
|
||||
"glc/ldb/search"
|
||||
"glc/ldb/storage"
|
||||
"glc/ldb/storage/indexword"
|
||||
@ -75,24 +74,13 @@ func (e *Engine) Search(searchKey string, system string, minDatetime string, max
|
||||
}
|
||||
}
|
||||
|
||||
var rs *search.SearchResult
|
||||
if len(kws) == 0 {
|
||||
// 无条件浏览模式
|
||||
rs = search.SearchLogData(e.storeName, currentDocId, forward, minDatetime, maxDatetime)
|
||||
} else {
|
||||
// 多关键词查询模式
|
||||
rs = search.SearchWordIndex(e.storeName, kws, currentDocId, forward, minDatetime, maxDatetime)
|
||||
return search.SearchLogData(e.storeName, currentDocId, forward, minDatetime, maxDatetime)
|
||||
}
|
||||
|
||||
if !forward {
|
||||
// 修复最多匹配件数:检索(非检索更多)数据量少于1页时,最多匹配件数=检索结果件数,避免个别特殊场景下两者不一致
|
||||
size := len(rs.Data)
|
||||
if size < conf.GetPageSize() {
|
||||
rs.Count = cmn.IntToString(size)
|
||||
}
|
||||
}
|
||||
|
||||
return rs
|
||||
// 多关键词查询模式
|
||||
return search.SearchWordIndex(e.storeName, kws, currentDocId, forward, minDatetime, maxDatetime)
|
||||
}
|
||||
|
||||
// 添加日志
|
||||
|
||||
@ -18,9 +18,10 @@ import (
|
||||
)
|
||||
|
||||
type SearchResult struct {
|
||||
Total string `json:"total,omitempty"` // 日志总量件数(用10进制字符串形式以避免出现科学计数法)
|
||||
Count string `json:"count,omitempty"` // 当前条件最多匹配件数(用10进制字符串形式以避免出现科学计数法)
|
||||
Data []*logdata.LogDataModel `json:"data,omitempty"` // 检索结果数据(日志文档数组)
|
||||
Total string `json:"total,omitempty"` // 日志总量件数(用10进制字符串形式以避免出现科学计数法)
|
||||
Count string `json:"count,omitempty"` // 当前条件最多匹配件数(用10进制字符串形式以避免出现科学计数法)
|
||||
PageSize string `json:"pagesize,omitempty"` // 每次检索件数
|
||||
Data []*logdata.LogDataModel `json:"data,omitempty"` // 检索结果数据(日志文档数组)
|
||||
}
|
||||
|
||||
type WidxStorage struct {
|
||||
|
||||
@ -33,5 +33,16 @@ func LogSearchController(req *gweb.HttpRequest) *gweb.HttpResult {
|
||||
|
||||
eng := ldb.NewEngine(storeName)
|
||||
rs := eng.Search(searchKey, system, datetimeFrom, datetimeTo, loglevel, currentId, forward)
|
||||
|
||||
// 检索结果后处理
|
||||
rs.PageSize = cmn.IntToString(conf.GetPageSize())
|
||||
if !forward {
|
||||
// 修复最多匹配件数:检索(非检索更多)数据量少于1页时,最多匹配件数=检索结果件数,避免个别特殊场景下两者不一致
|
||||
size := len(rs.Data)
|
||||
if size < conf.GetPageSize() {
|
||||
rs.Count = cmn.IntToString(size)
|
||||
}
|
||||
}
|
||||
|
||||
return gweb.Result(rs)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user