feat:优化es查询规则
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user