feat:优化信息,完善es查询,完善网站首页公司信息查询

This commit is contained in:
henry
2021-12-23 18:12:33 +08:00
parent eb2cfcb06b
commit b62ee9c3d9
4 changed files with 68 additions and 30 deletions

View File

@ -3,7 +3,9 @@ package service
import (
"SciencesServer/serve/es"
"SciencesServer/serve/logger"
"SciencesServer/utils"
"encoding/json"
"fmt"
)
type ESPatent struct {
@ -19,14 +21,30 @@ func (this *ESPatent) Index() string {
}
func (this *ESPatent) Create() error {
if this.Industry != "" {
this.Title = this.Industry + " - " + this.Title
}
_bytes, _ := json.Marshal(this)
return es.Create(this.Index(), _bytes)
}
func (this *ESPatent) Search(page, pageSize int, params map[string]interface{}) (interface{}, error) {
func (this *ESPatent) Search(page, pageSize int) (interface{}, error) {
mustParams := make(map[string]interface{}, 0)
shouldParams := make(map[string]interface{}, 0)
fmt.Println(utils.AnyToJSON(this))
if this.Title != "" {
shouldParams["title"] = this.Title
}
if this.Industry != "" {
mustParams["title"] = this.Industry
}
fmt.Println(mustParams)
fmt.Println(shouldParams)
out, err := es.Search(this, this.Index(), &es.SearchParams{
MustParams: nil,
ShouldParams: params,
MustParams: mustParams,
ShouldParams: shouldParams,
}, page, pageSize)
if err != nil {