瀏覽代碼

fix:补充提交

master
燕鹏 3 年前
父節點
當前提交
810b30e54a
  1. 34
      utils/EsUtil.go

34
utils/EsUtil.go

@ -4,9 +4,13 @@ import (
"beeblog/models"
"context"
"fmt"
beego "github.com/beego/beego/v2/server/web"
"github.com/olivere/elastic"
"log"
"os"
"reflect"
"strconv"
"time"
)
var client *elastic.Client
@ -44,21 +48,21 @@ const mapping = `
}
}`
//func init() {
// host, _ := beego.AppConfig.String("eshost")
// var err error
// client, err = elastic.NewClient(
// elastic.SetURL(host),
// elastic.SetSniff(false),
// elastic.SetHealthcheckInterval(10*time.Second),
// elastic.SetGzip(true),
// elastic.SetErrorLog(log.New(os.Stderr, "ELASTIC ", log.LstdFlags)),
// elastic.SetInfoLog(log.New(os.Stdout, "", log.LstdFlags)))
//
// if err != nil {
// panic(err)
// }
//}
func init() {
host, _ := beego.AppConfig.String("eshost")
var err error
client, err = elastic.NewClient(
elastic.SetURL(host),
elastic.SetSniff(false),
elastic.SetHealthcheckInterval(10*time.Second),
elastic.SetGzip(true),
elastic.SetErrorLog(log.New(os.Stderr, "ELASTIC ", log.LstdFlags)),
elastic.SetInfoLog(log.New(os.Stdout, "", log.LstdFlags)))
if err != nil {
panic(err)
}
}
func Index() {
ctx := context.Background()

載入中…
取消
儲存