feat:优化es查询规则

This commit is contained in:
henry
2021-12-24 09:13:16 +08:00
parent b62ee9c3d9
commit ebf74435ef
5 changed files with 39 additions and 55 deletions

View File

@ -21,30 +21,25 @@ 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) (interface{}, error) {
termParams := make(map[string]interface{}, 0)
mustParams := make(map[string]interface{}, 0)
shouldParams := make(map[string]interface{}, 0)
fmt.Println(utils.AnyToJSON(this))
if this.Title != "" {
shouldParams["title"] = this.Title
mustParams["title"] = this.Title
}
if this.Industry != "" {
mustParams["title"] = this.Industry
termParams["title"] = this.Industry
}
fmt.Println(mustParams)
fmt.Println(shouldParams)
out, err := es.Search(this, this.Index(), &es.SearchParams{
MustParams: mustParams,
ShouldParams: shouldParams,
TermParams: termParams,
MustParams: mustParams,
}, page, pageSize)
if err != nil {