|
|
|
@@ -41,11 +41,11 @@ func Search(ctx *context.Context) { |
|
|
|
|
|
|
|
boolQ := elastic.NewBoolQuery() |
|
|
|
|
|
|
|
nameQuery := elastic.NewTermQuery("name", Key) |
|
|
|
descriptionQuery := elastic.NewTermQuery("description", Key) |
|
|
|
|
|
|
|
boolQ.Should(nameQuery, descriptionQuery) |
|
|
|
//boolQ.Filter(descriptionQuery) |
|
|
|
if Key != "" { |
|
|
|
nameQuery := elastic.NewTermQuery("name", Key) |
|
|
|
descriptionQuery := elastic.NewTermQuery("description", Key) |
|
|
|
boolQ.Should(nameQuery, descriptionQuery) |
|
|
|
} |
|
|
|
|
|
|
|
res, err := client.Search(TableName + "-es-index").Query(boolQ).Do(ctx.Req.Context()) |
|
|
|
ctx.JSON(200, res) |
|
|
|
|