mirror of
https://github.com/gotoeasy/glogcenter.git
synced 2025-09-15 12:58:34 +08:00
重构优化
This commit is contained in:
parent
e7ab2b0648
commit
68b548b3c1
@ -62,7 +62,10 @@ func (e *Engine) Search(searchKey string, pageSize int, currentDocId uint32, for
|
|||||||
idxw := indexword.NewWordIndexStorage(e.storeName, word)
|
idxw := indexword.NewWordIndexStorage(e.storeName, word)
|
||||||
if idxw.GetTotalCount(word) < 1 {
|
if idxw.GetTotalCount(word) < 1 {
|
||||||
log.Println("关键词", word, "没有索引数据,直接返回空结果")
|
log.Println("关键词", word, "没有索引数据,直接返回空结果")
|
||||||
return new(search.SearchResult)
|
rs := new(search.SearchResult)
|
||||||
|
rs.Total = cmn.Uint32ToString(e.logStorage.TotalCount())
|
||||||
|
rs.Count = cmn.Uint32ToString(0)
|
||||||
|
return rs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ type WidxStorage struct {
|
|||||||
idxwordStorage *indexword.WordIndexStorage
|
idxwordStorage *indexword.WordIndexStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
// 多关键词浏览日志
|
// 多关键词时计算关键词索引交集
|
||||||
func Search(storeName string, kws []string, pageSize int, currentDocId uint32, forward bool) *SearchResult {
|
func Search(storeName string, kws []string, pageSize int, currentDocId uint32, forward bool) *SearchResult {
|
||||||
storeLogData := storage.NewLogDataStorageHandle(storeName) // 数据
|
storeLogData := storage.NewLogDataStorageHandle(storeName) // 数据
|
||||||
var widxs []*WidxStorage
|
var widxs []*WidxStorage
|
||||||
@ -106,7 +106,7 @@ func SearchLogData(storeName string, pageSize int, currentDocId uint32, forward
|
|||||||
return rs
|
return rs
|
||||||
}
|
}
|
||||||
|
|
||||||
// 有关键词时走索引检索
|
// 单关键词时走一个关键词索引检索
|
||||||
func SearchWordIndex(storeName string, word string, pageSize int, currentDocId uint32, forward bool) *SearchResult {
|
func SearchWordIndex(storeName string, word string, pageSize int, currentDocId uint32, forward bool) *SearchResult {
|
||||||
|
|
||||||
var rs = new(SearchResult) // 检索结果
|
var rs = new(SearchResult) // 检索结果
|
||||||
|
|||||||
@ -116,7 +116,7 @@ export default {
|
|||||||
|
|
||||||
api.search(params).then(rs => {
|
api.search(params).then(rs => {
|
||||||
let res = rs.data
|
let res = rs.data
|
||||||
if (res.success && res.result.data.length) {
|
if (res.success && res.result.data && res.result.data.length) {
|
||||||
this.data.push(...res.result.data)
|
this.data.push(...res.result.data)
|
||||||
this.info = `日志总量 ${res.result.total} 条,当前条件最多匹配 ${res.result.count} 条,正展示前 ${this.data.length} 条`
|
this.info = `日志总量 ${res.result.total} 条,当前条件最多匹配 ${res.result.count} 条,正展示前 ${this.data.length} 条`
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ export default {
|
|||||||
let res = rs.data
|
let res = rs.data
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
// console.info(res,"xxxxxxxxxxxxxxxxxxxxxxx")
|
// console.info(res,"xxxxxxxxxxxxxxxxxxxxxxx")
|
||||||
this.data = res.result.data;
|
this.data = res.result.data || [];
|
||||||
document.querySelector('.el-scrollbar__wrap').scrollTop = 0; // 滚动到顶部
|
document.querySelector('.el-scrollbar__wrap').scrollTop = 0; // 滚动到顶部
|
||||||
this.info = `日志总量 ${res.result.total} 条,当前条件最多匹配 ${res.result.count} 条,正展示前 ${this.data.length} 条`
|
this.info = `日志总量 ${res.result.total} 条,当前条件最多匹配 ${res.result.count} 条,正展示前 ${this.data.length} 条`
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user