diff --git a/routers/search.go b/routers/search.go index 67ea72228..951414ee7 100644 --- a/routers/search.go +++ b/routers/search.go @@ -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)