重构优化

This commit is contained in:
gotoeasy 2022-07-03 17:03:09 +08:00
parent e7ab2b0648
commit 68b548b3c1
3 changed files with 8 additions and 5 deletions

View File

@ -62,7 +62,10 @@ func (e *Engine) Search(searchKey string, pageSize int, currentDocId uint32, for
idxw := indexword.NewWordIndexStorage(e.storeName, word)
if idxw.GetTotalCount(word) < 1 {
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
}
}

View File

@ -27,7 +27,7 @@ type WidxStorage struct {
idxwordStorage *indexword.WordIndexStorage
}
// 多关键词浏览日志
// 多关键词时计算关键词索引交集
func Search(storeName string, kws []string, pageSize int, currentDocId uint32, forward bool) *SearchResult {
storeLogData := storage.NewLogDataStorageHandle(storeName) // 数据
var widxs []*WidxStorage
@ -106,7 +106,7 @@ func SearchLogData(storeName string, pageSize int, currentDocId uint32, forward
return rs
}
// 有关键词时走索引检索
// 单关键词时走一个关键词索引检索
func SearchWordIndex(storeName string, word string, pageSize int, currentDocId uint32, forward bool) *SearchResult {
var rs = new(SearchResult) // 检索结果

View File

@ -116,7 +116,7 @@ export default {
api.search(params).then(rs => {
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.info = `日志总量 ${res.result.total} 条,当前条件最多匹配 ${res.result.count} 条,正展示前 ${this.data.length}`
}
@ -131,7 +131,7 @@ export default {
let res = rs.data
if (res.success) {
// console.info(res,"xxxxxxxxxxxxxxxxxxxxxxx")
this.data = res.result.data;
this.data = res.result.data || [];
document.querySelector('.el-scrollbar__wrap').scrollTop = 0; //
this.info = `日志总量 ${res.result.total} 条,当前条件最多匹配 ${res.result.count} 条,正展示前 ${this.data.length}`
}