Browse Source

提交代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.3.2^2
zouap 4 years ago
parent
commit
ef88d92605
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      routers/search.go

+ 4
- 2
routers/search.go View File

@@ -2,6 +2,7 @@ package routers

import (
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/log"
"github.com/olivere/elastic/v7"
)

@@ -44,12 +45,13 @@ func Search(ctx *context.Context) {
descriptionQuery := elastic.NewTermQuery("description", Key)
boolQ.Should(nameQuery, descriptionQuery)
res, err := client.Search(TableName + "-es-index").Query(boolQ).Do(ctx.Req.Context())
if err != nil {
if err == nil {
ctx.JSON(200, res)
}
} else {
log.Info("query all content.")
res, err := client.Search(TableName + "-es-index").Do(ctx.Req.Context())
if err != nil {
if err == nil {
ctx.JSON(200, res)
}
}


Loading…
Cancel
Save