|
@@ -1,12 +1,12 @@
|
|
|
package logic
|
|
|
|
|
|
-import "C"
|
|
|
import (
|
|
|
cm "app.yhyue.com/moapp/jybase/common"
|
|
|
. "app.yhyue.com/moapp/jybase/encrypt"
|
|
|
elastic "app.yhyue.com/moapp/jybase/esv1"
|
|
|
"context"
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
+ . "knowledgeBase/rpc/knowledge/init"
|
|
|
"knowledgeBase/rpc/knowledge/internal/svc"
|
|
|
"knowledgeBase/rpc/knowledge/knowledgeclient"
|
|
|
"knowledgeBase/rpc/knowledge/util"
|
|
@@ -37,25 +37,19 @@ func (l *RecommendAnswerLogic) RecommendAnswer(in *knowledgeclient.FindAnswerReq
|
|
|
//根据问题进行分词
|
|
|
keyWords = util.HttpDo(in.Question)
|
|
|
log.Println("问题分词关键字:", keyWords)
|
|
|
- if keyWords != "" {
|
|
|
- var query = util.DSL4SearchByKwsOrid(keyWords, SE.Decode4Hex(in.RobotEntId))
|
|
|
- res := elastic.GetAllByNgram(C.Es.Index, C.Es.Type, query, "", "", searchField, 0, 3, 0, false)
|
|
|
+ var query = util.DSL4SearchByKwsOrid(keyWords, SE.Decode4Hex(in.RobotEntId))
|
|
|
+ res := elastic.GetAllByNgram(C.Es.Index, C.Es.Type, query, "", "", searchField, 0, 3, 0, false)
|
|
|
|
|
|
- if res != nil && len(*res) > 0 {
|
|
|
- for _, val := range *res {
|
|
|
- answers = append(answers, &knowledgeclient.Question{
|
|
|
- Question: cm.ObjToString(val["question"]),
|
|
|
- Answer: cm.ObjToString(val["answer"]),
|
|
|
- })
|
|
|
- }
|
|
|
+ if res != nil && len(*res) > 0 {
|
|
|
+ for _, val := range *res {
|
|
|
+ answers = append(answers, &knowledgeclient.Question{
|
|
|
+ Question: cm.ObjToString(val["question"]),
|
|
|
+ Answer: cm.ObjToString(val["answer"]),
|
|
|
+ })
|
|
|
}
|
|
|
- result.ErrorCode = 0
|
|
|
- result.ErrorMsg = "请求成功"
|
|
|
- result.Data = answers
|
|
|
- } else {
|
|
|
- result.ErrorCode = -1
|
|
|
- result.ErrorMsg = "分词出错"
|
|
|
- result.Data = answers
|
|
|
}
|
|
|
+ result.ErrorCode = 0
|
|
|
+ result.ErrorMsg = "请求成功"
|
|
|
+ result.Data = answers
|
|
|
return result, nil
|
|
|
}
|