|
@@ -6,6 +6,7 @@ import (
|
|
|
"log"
|
|
|
"regexp"
|
|
|
"strings"
|
|
|
+ "time"
|
|
|
|
|
|
"app.yhyue.com/moapp/jy_docs/rpc/stdlib/stdlib"
|
|
|
"app.yhyue.com/moapp/jy_docs/services/model"
|
|
@@ -36,6 +37,7 @@ func FindDocumentById(id int) {
|
|
|
}
|
|
|
|
|
|
func DocQuery(in *stdlib.DocQueryRequest) *stdlib.DocQueryResponse {
|
|
|
+ startNow := time.Now()
|
|
|
defer common.Catch()
|
|
|
in.KeyWord = strings.TrimSpace(in.KeyWord)
|
|
|
musts := []string{}
|
|
@@ -88,6 +90,8 @@ func DocQuery(in *stdlib.DocQueryRequest) *stdlib.DocQueryResponse {
|
|
|
}
|
|
|
log.Println("query:", query)
|
|
|
total, list := elastic.GetBySearchType(model.Es_JyDoc, "dfs_query_then_fetch", query)
|
|
|
+ log.Println("es 查询耗时:", time.Since(startNow))
|
|
|
+ step2 := time.Now()
|
|
|
docs := []*stdlib.Doc{}
|
|
|
//获取我购买的文档
|
|
|
if list != nil {
|
|
@@ -110,6 +114,7 @@ func DocQuery(in *stdlib.DocQueryRequest) *stdlib.DocQueryResponse {
|
|
|
tags := strings.Split(common.ObjToString(v["docTags"]), ",")
|
|
|
tmptags := []string{}
|
|
|
subTag := ""
|
|
|
+ step3 := time.Now()
|
|
|
for i := 0; i < len(tags); i++ {
|
|
|
dtpKey := fmt.Sprintf("p_%s_1_tag", tags[i]) //一级tag
|
|
|
if _, ok := partner.DocClassMap[dtpKey]; ok && len(tmptags) == 0 {
|
|
@@ -122,6 +127,7 @@ func DocQuery(in *stdlib.DocQueryRequest) *stdlib.DocQueryResponse {
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
+ log.Println("step3", time.Since(step3))
|
|
|
doc := &stdlib.Doc{
|
|
|
DocId: common.ObjToString(v["id"]),
|
|
|
DocName: common.ObjToString(v["docName"]),
|
|
@@ -148,6 +154,8 @@ func DocQuery(in *stdlib.DocQueryRequest) *stdlib.DocQueryResponse {
|
|
|
docs = append(docs, doc)
|
|
|
}
|
|
|
}
|
|
|
+ log.Println("step2", time.Since(step2))
|
|
|
+ log.Println("end", time.Since(startNow))
|
|
|
return &stdlib.DocQueryResponse{
|
|
|
Total: total,
|
|
|
Docs: docs,
|