|
@@ -81,8 +81,11 @@ func ProjectListData(productId int, appid, projectName, winner, times string, is
|
|
|
}
|
|
|
userProduct := &model.UserProduct{}
|
|
|
db.GetSFISDB().First(userProduct, &model.UserProduct{AppID: appid, ProductID: productId})
|
|
|
- repl := GetAllByNgram(Es, INDEX, TYPE, qstr, "", pjt_sort, fields, 0, userProduct.DataNumLimitOneTimes, 0, false)
|
|
|
- if repl != nil && len(*repl) > 0 {
|
|
|
+ repl, err := GetAllByNgram(Es, INDEX, TYPE, qstr, "", pjt_sort, fields, 0, userProduct.DataNumLimitOneTimes, 0, false)
|
|
|
+ if err != nil {
|
|
|
+ err = errors.New("查询失败")
|
|
|
+ return
|
|
|
+ } else if repl != nil && len(*repl) > 0 {
|
|
|
data = *repl
|
|
|
for _, i := range data {
|
|
|
i["project_id"] = SE.EncodeString(utils.ObjToString(i["_id"]))
|
|
@@ -92,7 +95,7 @@ func ProjectListData(productId int, appid, projectName, winner, times string, is
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func GetAllByNgram(Es *elastic.Elastic, index, itype, qstr, findfields, order, fields string, start, limit, count int, highlight bool) *[]map[string]interface{} {
|
|
|
+func GetAllByNgram(Es *elastic.Elastic, index, itype, qstr, findfields, order, fields string, start, limit, count int, highlight bool) (*[]map[string]interface{}, error) {
|
|
|
if qstr != "" {
|
|
|
if highlight {
|
|
|
ws := []string{}
|
|
@@ -113,6 +116,6 @@ func GetAllByNgram(Es *elastic.Elastic, index, itype, qstr, findfields, order, f
|
|
|
global.Logger.Info("GetAllByNgram方法es查询", zap.Any("es语句", qstr))
|
|
|
return Es.Get(index, itype, qstr)
|
|
|
} else {
|
|
|
- return nil
|
|
|
+ return nil, nil
|
|
|
}
|
|
|
}
|