feat:完善项目信息

This commit is contained in:
henry
2022-01-20 11:51:02 +08:00
parent 9348c8970c
commit b87cd837be
23 changed files with 86 additions and 83 deletions

View File

@ -3,6 +3,7 @@ package manage
import (
"SciencesServer/app/api/enterprise/model"
"SciencesServer/app/basic/config"
"SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
"SciencesServer/app/session"
@ -102,14 +103,14 @@ func (c *Company) Product(id uint64, page, pageSize int) ([]*CompanyProductInfo,
}
// Match 匹配信息
func (c *Company) Match(title string, industrys, keywords []string) ([]*CompanyMatchInfo, error) {
func (c *Company) Match(title string, industrys, keywords []string) (*controller.ReturnPages, error) {
params := strings.Join([]string{
title, strings.Join(industrys, ","), strings.Join(keywords, ","),
}, ",")
manage := service.NewESManage(
service.WithManageIdentity(config.TenantUserIdentityForCompany),
)
out, err := manage.Search(0, 0, map[string]interface{}{
out, count, err := manage.Search(0, 0, map[string]interface{}{
"title": params, "industry": params, "keyword": params, "research": params,
})
if err != nil {
@ -145,7 +146,7 @@ func (c *Company) Match(title string, industrys, keywords []string) ([]*CompanyM
Keywords: v.GetKeywordAttribute(),
})
}
return list, nil
return &controller.ReturnPages{Data: list, Count: count}, nil
}
func NewCompany() CompanyHandle {

View File

@ -162,7 +162,7 @@ func (c *Expert) Instance(name, mobile string, page, pageSize int) (*controller.
}
// Match 匹配信息
func (c *Expert) Match(title string, industrys, keywords []string) ([]*ExpertMatchInfo, error) {
func (c *Expert) Match(title string, industrys, keywords []string) (*controller.ReturnPages, error) {
params := strings.Join([]string{
title, strings.Join(industrys, ","), strings.Join(keywords, ","),
}, ",")
@ -170,7 +170,7 @@ func (c *Expert) Match(title string, industrys, keywords []string) ([]*ExpertMat
manage := service.NewESManage(
service.WithManageIdentity(config.TenantUserIdentityForExpert),
)
out, err := manage.Search(0, 0, map[string]interface{}{
out, count, err := manage.Search(0, 0, map[string]interface{}{
"title": params, "industry": params, "keyword": params, "research": params,
})
if err != nil {
@ -202,7 +202,7 @@ func (c *Expert) Match(title string, industrys, keywords []string) ([]*ExpertMat
PatentTitles: strings.Split(v.PatentTitle, "&&"),
})
}
return list, nil
return &controller.ReturnPages{Data: list, Count: count}, nil
}
// Detail 详细信息

View File

@ -50,14 +50,14 @@ func (c *Laboratory) Instance() (*controller.ReturnPages, error) {
}
// Match 匹配信息
func (c *Laboratory) Match(title string, industrys, keywords []string) ([]*LaboratoryMatchInfo, error) {
func (c *Laboratory) Match(title string, industrys, keywords []string) (*controller.ReturnPages, error) {
params := strings.Join([]string{
title, strings.Join(industrys, ","), strings.Join(keywords, ","),
}, ",")
manage := service.NewESManage(
service.WithManageIdentity(config.TenantUserIdentityForLaboratory),
)
out, err := manage.Search(0, 0, map[string]interface{}{
out, count, err := manage.Search(0, 0, map[string]interface{}{
"title": params, "industry": params, "keyword": params, "research": params,
})
if err != nil {
@ -87,7 +87,7 @@ func (c *Laboratory) Match(title string, industrys, keywords []string) ([]*Labor
Researchs: v.GetResearchAttribute(),
})
}
return list, nil
return &controller.ReturnPages{Data: list, Count: count}, nil
}
// Detail 实验室信息

View File

@ -80,7 +80,7 @@ func (c *Achievement) Instance(status, page, pageSize int) (*controller.ReturnPa
}
// Match 匹配信息
func (c *Achievement) Match(title string, industrys, keywords []string) ([]*AchievementMatchInfo, error) {
func (c *Achievement) Match(title string, industrys, keywords []string) (*controller.ReturnPages, error) {
params := strings.Join([]string{
title, strings.Join(industrys, ","), strings.Join(keywords, ","),
}, ",")
@ -89,7 +89,7 @@ func (c *Achievement) Match(title string, industrys, keywords []string) ([]*Achi
service.WithAchievementIndustry(params),
service.WithAchievementKeyword(params),
)
out, err := achievement.Search(0, 0)
out, count, err := achievement.Search(0, 0)
if err != nil {
return nil, err
@ -123,7 +123,7 @@ func (c *Achievement) Match(title string, industrys, keywords []string) ([]*Achi
Customers: mTechnologyAchievement.GetCustomerAttribute(),
})
}
return list, nil
return &controller.ReturnPages{Data: list, Count: count}, nil
}
// Detail 详情信息

View File

@ -193,7 +193,7 @@ func (c *Patent) List(kind int, title, applyCode, openCode, ipcCode string, page
}
// Match 搜索信息
func (c *Patent) Match(title string, industrys, keywords []string) ([]*PatentMatchInfo, error) {
func (c *Patent) Match(title string, industrys, keywords []string) (*controller.ReturnPages, error) {
params := strings.Join([]string{
title, strings.Join(industrys, ","), strings.Join(keywords, ","),
}, ",")
@ -201,7 +201,7 @@ func (c *Patent) Match(title string, industrys, keywords []string) ([]*PatentMat
service.WithPatentTitle(params),
service.WithPatentIndustry(params),
)
out, err := patent.Search(0, 0)
out, count, err := patent.Search(0, 0)
if err != nil {
return nil, err
@ -229,7 +229,7 @@ func (c *Patent) Match(title string, industrys, keywords []string) ([]*PatentMat
ID: v.GetEncodeID(), Title: v.Title, Description: v.Description, ApplyAt: v.ApplyAt,
})
}
return list, nil
return &controller.ReturnPages{Data: list, Count: count}, nil
}
// Detail 详细信息

View File

@ -50,33 +50,33 @@ type (
}
)
var matchHandle = map[int]func(title string, industrys, keywords []string) (interface{}, error){
var matchHandle = map[int]func(title string, industrys, keywords []string) (*controller.ReturnPages, error){
1: matchAchievement, 2: matchPatent, 3: matchExpect, 4: matchLaboratory, 5: matchCompany,
}
// matchAchievement 成果匹配
func matchAchievement(title string, industrys, keywords []string) (interface{}, error) {
func matchAchievement(title string, industrys, keywords []string) (*controller.ReturnPages, error) {
return (&Achievement{}).Match(title, industrys, keywords)
}
// matchPatent 专利匹配
func matchPatent(title string, industrys, keywords []string) (interface{}, error) {
func matchPatent(title string, industrys, keywords []string) (*controller.ReturnPages, error) {
return (&Patent{}).Match(title, industrys, keywords)
}
// matchExpect 专家匹配
func matchExpect(title string, industrys, keywords []string) (interface{}, error) {
func matchExpect(title string, industrys, keywords []string) (*controller.ReturnPages, error) {
return (&manage.Expert{}).Match(title, industrys, keywords)
}
// matchLaboratory 实验室匹配
func matchLaboratory(title string, industrys, keywords []string) (interface{}, error) {
func matchLaboratory(title string, industrys, keywords []string) (*controller.ReturnPages, error) {
return (&manage.Laboratory{}).Match(title, industrys, keywords)
}
// matchCompany 公司匹配
func matchCompany(title string, industrys, keywords []string) (interface{}, error) {
func matchCompany(title string, industrys, keywords []string) (*controller.ReturnPages, error) {
return nil, nil
}

View File

@ -59,7 +59,7 @@ func (*ES) Search(c *gin.Context) {
// service.WithPatentTitle(form.Param),
// service.WithPatentIndustry(form.Industry),
//)
data, err := manage.Search(1, 10, nil)
data, _, err := manage.Search(1, 10, nil)
for _, v := range data.([]interface{}) {
fmt.Println(reflect.TypeOf(v).String())

View File

@ -11,7 +11,7 @@ type Search struct{}
func (*Search) Launch(c *gin.Context) {
form := &struct {
Mode int `json:"mode" form:"mode" binding:"required"`
Keyword string `json:"keyword" form:"keyword" binding:"required"`
Keyword string `json:"keyword" form:"keyword"`
Industry string `json:"industry" form:"industry"`
Params map[string]interface{} `json:"params" form:"params"`
api.PageForm

View File

@ -3,6 +3,7 @@ package manage
import (
"SciencesServer/app/api/website/model"
"SciencesServer/app/basic/config"
"SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
config2 "SciencesServer/config"
@ -103,7 +104,7 @@ func laboratory(ids []uint64) (interface{}, error) {
return out, nil
}
func (c *Search) Launch(identity int, param, industry string, page, pageSize int) (interface{}, error) {
func (c *Search) Launch(identity int, param, industry string, page, pageSize int) (*controller.ReturnPages, error) {
manage := service.NewESManage(
service.WithManageIdentity(identity),
service.WithManageTitle(param),
@ -111,7 +112,7 @@ func (c *Search) Launch(identity int, param, industry string, page, pageSize int
service.WithManageKeyword(param),
service.WithManageResearch(param),
)
out, err := manage.Search(page, pageSize, nil)
out, count, err := manage.Search(page, pageSize, nil)
if err != nil {
return nil, err
@ -129,7 +130,12 @@ func (c *Search) Launch(identity int, param, industry string, page, pageSize int
if !has {
return nil, errors.New("操作错误,未知的身份信息")
}
return handle(ids)
var data interface{}
if data, err = handle(ids); err != nil {
return nil, err
}
return &controller.ReturnPages{Data: data, Count: count}, nil
}
func NewSearch() SearchHandle {

View File

@ -3,6 +3,7 @@ package search
import (
"SciencesServer/app/api/website/model"
"SciencesServer/app/basic/config"
"SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
config2 "SciencesServer/config"
@ -18,7 +19,7 @@ type (
}
)
func achievementSearch(page, pageSize int, keyword, industry string, params map[string]interface{}) (interface{}, error) {
func achievementSearch(page, pageSize int, keyword, industry string, params map[string]interface{}) (*controller.ReturnPages, error) {
manage := service.NewESAchievement(
service.WithAchievementTitle(keyword),
service.WithAchievementKeyword(keyword),
@ -26,7 +27,7 @@ func achievementSearch(page, pageSize int, keyword, industry string, params map[
if industry != "" {
service.WithAchievementIndustry(keyword)(manage)
}
out, err := manage.Search(page, pageSize)
out, count, err := manage.Search(page, pageSize)
if err != nil {
return nil, err
@ -65,5 +66,5 @@ func achievementSearch(page, pageSize int, keyword, industry string, params map[
Industrys: _industrys, Keywords: v.GetKeywordAttribute(),
})
}
return list, nil
return &controller.ReturnPages{Data: list, Count: count}, nil
}

View File

@ -3,6 +3,7 @@ package search
import (
"SciencesServer/app/api/website/model"
"SciencesServer/app/basic/config"
"SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
config2 "SciencesServer/config"
@ -22,7 +23,7 @@ type (
)
// searchCompany 公司搜索
func searchCompany(page, pageSize int, keyword, industry string, params map[string]interface{}) (interface{}, error) {
func searchCompany(page, pageSize int, keyword, industry string, params map[string]interface{}) (*controller.ReturnPages, error) {
manage := service.NewESManage(
service.WithManageIdentity(config.TenantUserIdentityForCompany),
service.WithManageTitle(keyword),
@ -32,7 +33,9 @@ func searchCompany(page, pageSize int, keyword, industry string, params map[stri
if industry != "" {
service.WithManageIndustry(industry)(manage)
}
out, err := manage.Search(page, pageSize, nil)
out, count, err := manage.Search(page, pageSize, nil)
companys := make([]*model2.ManageCompany, 0)
if err != nil {
return nil, err
@ -48,8 +51,6 @@ func searchCompany(page, pageSize int, keyword, industry string, params map[stri
}
mManageCompany := model.NewManageCompany()
companys := make([]*model2.ManageCompany, 0)
if err = model2.ScanFields(mManageCompany.ManageCompany, &companys, []string{"id", "name", "kind", "image", "product",
"industry", "keyword", "url"}, &model2.ModelWhereOrder{Where: model2.NewWhereIn("id", ids)}); err != nil {
return nil, err
@ -68,5 +69,5 @@ func searchCompany(page, pageSize int, keyword, industry string, params map[stri
Product: v.Product, Industrys: _industrys, Keywords: v.GetKeywordAttribute(),
})
}
return list, nil
return &controller.ReturnPages{Data: list, Count: count}, nil
}

View File

@ -2,6 +2,7 @@ package search
import (
"SciencesServer/app/api/website/model"
"SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model"
"fmt"
"time"
@ -22,7 +23,7 @@ type (
)
// searchDemand 需求搜索
func searchDemand(page, pageSize int, keyword, industry string, params map[string]interface{}) (interface{}, error) {
func searchDemand(page, pageSize int, keyword, industry string, params map[string]interface{}) (*controller.ReturnPages, error) {
mTechnologyDemand := model.NewTechnologyDemand()
where := make([]*model2.ModelWhere, 0)
@ -39,7 +40,9 @@ func searchDemand(page, pageSize int, keyword, industry string, params map[strin
where = append(where, model2.NewWhere(k, v))
}
}
out, err := mTechnologyDemand.Demand(where...)
var count int64
out, err := mTechnologyDemand.Demand(page, pageSize, &count, where...)
if err != nil {
return nil, err
@ -57,5 +60,5 @@ func searchDemand(page, pageSize int, keyword, industry string, params map[strin
CompanyKind: v.CompanyKind,
})
}
return list, nil
return &controller.ReturnPages{Data: list, Count: count}, nil
}

View File

@ -3,6 +3,7 @@ package search
import (
"SciencesServer/app/api/website/model"
"SciencesServer/app/basic/config"
"SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
config2 "SciencesServer/config"
@ -19,7 +20,7 @@ type (
)
// searchExpert 专家搜索
func searchExpert(page, pageSize int, keyword, industry string, params map[string]interface{}) (interface{}, error) {
func searchExpert(page, pageSize int, keyword, industry string, params map[string]interface{}) (*controller.ReturnPages, error) {
manage := service.NewESManage(
service.WithManageIdentity(config.TenantUserIdentityForExpert),
service.WithManageTitle(keyword),
@ -29,7 +30,7 @@ func searchExpert(page, pageSize int, keyword, industry string, params map[strin
if industry != "" {
service.WithManageIndustry(industry)(manage)
}
out, err := manage.Search(page, pageSize, nil)
out, count, err := manage.Search(page, pageSize, nil)
if err != nil {
return nil, err
@ -66,5 +67,5 @@ func searchExpert(page, pageSize int, keyword, industry string, params map[strin
Industrys: _industrys, Keywords: v.GetKeywordAttribute(),
})
}
return list, nil
return &controller.ReturnPages{Data: list, Count: count}, nil
}

View File

@ -1,6 +1,7 @@
package search
import (
"SciencesServer/app/basic/controller"
"errors"
)
@ -8,7 +9,7 @@ type Instance struct{}
type InstanceHandle func() *Instance
var instanceHandle = map[int]func(int, int, string, string, map[string]interface{}) (interface{}, error){
var instanceHandle = map[int]func(int, int, string, string, map[string]interface{}) (*controller.ReturnPages, error){
1: searchCompany, 2: achievementSearch, 3: searchLaboratory,
4: searchPatent, 5: searchExpert, 6: searchDemand,
}

View File

@ -3,6 +3,7 @@ package search
import (
"SciencesServer/app/api/website/model"
"SciencesServer/app/basic/config"
"SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
config2 "SciencesServer/config"
@ -19,7 +20,7 @@ type (
)
// searchLaboratory 实验室搜索
func searchLaboratory(page, pageSize int, keyword, industry string, params map[string]interface{}) (interface{}, error) {
func searchLaboratory(page, pageSize int, keyword, industry string, params map[string]interface{}) (*controller.ReturnPages, error) {
manage := service.NewESManage(
service.WithManageIdentity(config.TenantUserIdentityForLaboratory),
service.WithManageTitle(keyword),
@ -29,7 +30,7 @@ func searchLaboratory(page, pageSize int, keyword, industry string, params map[s
if industry != "" {
service.WithManageIndustry(industry)(manage)
}
out, err := manage.Search(page, pageSize, nil)
out, count, err := manage.Search(page, pageSize, nil)
if err != nil {
return nil, err
@ -66,5 +67,5 @@ func searchLaboratory(page, pageSize int, keyword, industry string, params map[s
Industrys: _industrys, Keywords: v.GetKeywordAttribute(),
})
}
return list, nil
return &controller.ReturnPages{Data: list, Count: count}, nil
}

View File

@ -2,6 +2,7 @@ package search
import (
"SciencesServer/app/api/website/model"
"SciencesServer/app/basic/controller"
model2 "SciencesServer/app/common/model"
"SciencesServer/app/service"
)
@ -18,14 +19,14 @@ type (
)
// searchPatent 专利搜索
func searchPatent(page, pageSize int, keyword, industry string, params map[string]interface{}) (interface{}, error) {
func searchPatent(page, pageSize int, keyword, industry string, params map[string]interface{}) (*controller.ReturnPages, error) {
manage := service.NewESPatent(
service.WithPatentTitle(keyword),
)
if industry != "" {
service.WithPatentIndustry(industry)(manage)
}
out, err := manage.Search(page, pageSize)
out, count, err := manage.Search(page, pageSize)
if err != nil {
return nil, err
@ -55,5 +56,5 @@ func searchPatent(page, pageSize int, keyword, industry string, params map[strin
ID: v.GetEncodeID(), Kind: v.Kind, Title: v.Title, ApplyAt: v.ApplyAt, Description: v.Description,
})
}
return list, nil
return &controller.ReturnPages{Data: list, Count: count}, nil
}

View File

@ -34,7 +34,7 @@ func (c *Patent) Instance(title, industry string, page, pageSize int) (*controll
service.WithPatentTitle(title),
service.WithPatentIndustry(industry),
)
out, err := s.Search(page, pageSize)
out, count1, err := s.Search(page, pageSize)
list := make([]*PatentInfo, 0)
@ -66,7 +66,7 @@ func (c *Patent) Instance(title, industry string, page, pageSize int) (*controll
SysPatentInfo: v,
})
}
return &controller.ReturnPages{Data: list, Count: count}, nil
return &controller.ReturnPages{Data: list, Count: count1}, nil
}
// Detail 详细信息

View File

@ -15,7 +15,7 @@ type TechnologyDemandInfo struct {
CompanyKind int `json:"company_kind"`
}
func (m *TechnologyDemand) Demand(where ...*model.ModelWhere) ([]*TechnologyDemandInfo, error) {
func (m *TechnologyDemand) Demand(page, pageSize int, count *int64, where ...*model.ModelWhere) ([]*TechnologyDemandInfo, error) {
out := make([]*TechnologyDemandInfo, 0)
db := orm.GetDB().Table(m.TableName()+" AS d").
@ -31,9 +31,13 @@ func (m *TechnologyDemand) Demand(where ...*model.ModelWhere) ([]*TechnologyDema
db = db.Where(v.Condition, v.Value)
}
}
err := db.Order("d.id " + model.OrderModeToDesc).Scan(&out).Error
return out, err
if err := db.Count(count).Error; err != nil {
return nil, err
}
if err := db.Order("d.id " + model.OrderModeToDesc).Offset((page - 1) * pageSize).Limit(pageSize).Scan(&out).Error; err != nil {
return nil, err
}
return out, nil
}
// Distribution 分布信息

View File

@ -2,7 +2,6 @@ package service
import (
"SciencesServer/serve/es"
"SciencesServer/serve/logger"
"encoding/json"
"fmt"
)
@ -28,7 +27,7 @@ func (this *ESAchievement) Create() error {
return es.Create(this.Index(), fmt.Sprintf("%d", this.ID), _bytes)
}
func (this *ESAchievement) Search(page, pageSize int) (interface{}, error) {
func (this *ESAchievement) Search(page, pageSize int) (interface{}, int64, error) {
termParams := make(map[string]interface{}, 0)
mustParams := make(map[string]interface{}, 0)
@ -41,15 +40,10 @@ func (this *ESAchievement) Search(page, pageSize int) (interface{}, error) {
if this.Keyword != "" {
mustParams["keyword"] = this.Keyword
}
out, err := es.Search(this, this.Index(), &es.SearchParams{
return es.Search(this, this.Index(), &es.SearchParams{
TermParams: termParams,
MustParams: mustParams,
}, page, pageSize)
if err != nil {
logger.ErrorF("查询ES信息错误【%s】", err)
}
return out, nil
}
func WithAchievementID(id uint64) ESAchievementOption {

View File

@ -2,7 +2,6 @@ package service
import (
"SciencesServer/serve/es"
"SciencesServer/serve/logger"
"encoding/json"
"fmt"
)
@ -30,7 +29,7 @@ func (this *ESManage) Create() error {
return es.Create(this.Index(), fmt.Sprintf("%d", this.ID), _bytes)
}
func (this *ESManage) Search(page, pageSize int, params map[string]interface{}) (interface{}, error) {
func (this *ESManage) Search(page, pageSize int, params map[string]interface{}) (interface{}, int64, error) {
termParams := make(map[string]interface{}, 0)
shouldParams := make(map[string]interface{}, 0)
@ -51,15 +50,10 @@ func (this *ESManage) Search(page, pageSize int, params map[string]interface{})
shouldParams[k] = v
}
}
out, err := es.Search(this, this.Index(), &es.SearchParams{
return es.Search(this, this.Index(), &es.SearchParams{
TermParams: termParams,
ShouldParams: shouldParams,
}, page, pageSize)
if err != nil {
logger.ErrorF("查询ES信息错误【%s】", err)
}
return out, nil
}
func WithManageID(id uint64) ESManageOption {

View File

@ -2,7 +2,6 @@ package service
import (
"SciencesServer/serve/es"
"SciencesServer/serve/logger"
"encoding/json"
"fmt"
)
@ -28,7 +27,7 @@ func (this *ESPatent) Update() error {
return nil
}
func (this *ESPatent) Search(page, pageSize int) (interface{}, error) {
func (this *ESPatent) Search(page, pageSize int) (interface{}, int64, error) {
termParams := make(map[string]interface{}, 0)
mustParams := make(map[string]interface{}, 0)
@ -38,15 +37,10 @@ func (this *ESPatent) Search(page, pageSize int) (interface{}, error) {
if this.Industry != "" {
termParams["industry"] = this.Industry
}
out, err := es.Search(this, this.Index(), &es.SearchParams{
return es.Search(this, this.Index(), &es.SearchParams{
TermParams: termParams,
MustParams: mustParams,
}, page, pageSize)
if err != nil {
logger.ErrorF("查询ES信息错误【%s】", err)
}
return out, nil
}
func WithPatentID(id uint64) ESPatentOption {

View File

@ -87,11 +87,12 @@ func TestNewInstance2(t *testing.T) {
service := client.Search().Index("es_patent_index")
result, err := service.Pretty(true).Query(query).Do(context.Background())
result, err := service.From(1).Size(1).TrackTotalHits(true).Pretty(true).Query(query).Do(context.Background())
if err != nil {
panic(err)
}
t.Log(utils.AnyToJSON(result.Hits.TotalHits.Value))
for _, v := range result.Hits.Hits {
t.Log(string(v.Source))
}

View File

@ -37,7 +37,7 @@ func Update(index, id string, body []byte) error {
}
// Search 搜索操作
func Search(src interface{}, index string, params *SearchParams, page, pageSize int) ([]interface{}, error) {
func Search(src interface{}, index string, params *SearchParams, page, pageSize int) ([]interface{}, int64, error) {
query := elastic.NewBoolQuery()
if params != nil {
@ -66,10 +66,10 @@ func Search(src interface{}, index string, params *SearchParams, page, pageSize
// 游标分页
service = service.From((page - 1) * pageSize).Size(pageSize)
}
result, err := service.Pretty(true).Query(query).Do(context.Background())
result, err := service.TrackTotalHits(true).Pretty(true).Query(query).Do(context.Background())
if err != nil {
return nil, err
return nil, 0, err
}
out := make([]interface{}, 0)
@ -79,11 +79,11 @@ func Search(src interface{}, index string, params *SearchParams, page, pageSize
_src := reflect.New(_type).Interface()
if err = json.Unmarshal(hit.Source, _src); err != nil {
return nil, err
return nil, 0, err
}
out = append(out, _src)
}
return out, err
return out, result.Hits.TotalHits.Value, err
}
// Delete 删除操作