123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- package docs
- func AddDoc() {
- //ctx := context.TODO()
- //table := "chapter_logs_1"
- //
- ////
- //////// 创建索引
- //////err := ChapterLogs.CreateIndex(ctx, table)
- //////if err != nil {
- ////// logrus.Warnf("CreateIndex err:%+v", err)
- ////// //return
- //////}
- //////
- //// 添加数据
- //var (
- // tab = config.DB.Scopes(model.ChapterLogTableSetName(table))
- // q = query.Use(tab).ChapterLog.Table("")
- //)
- //
- //lists, err := q.Limit(100).Find() // 4.6以后的数据
- //if err != nil {
- // logrus.Warnf("Find err:%+v", err)
- // return
- //}
- //for _, v := range lists {
- // err = eapi.Insert(ctx, table, v.ID, v)
- // if err != nil {
- // logrus.Warnf("Insert err:%+v", err)
- // return
- // }
- //}
- //query := map[string]interface{}{
- // "query": map[string]interface{}{
- // "match_phrase": map[string]interface{}{
- // "extra": `{"type":1}`,
- // },
- // },
- // //"aggs": map[string]interface{}{ // 合查询语句的简写
- // // "count_name": map[string]interface{}{ // 给聚合查询取个名字,
- // // "value_count": map[string]interface{}{
- // // "field": "name.keyword", //
- // // },
- // // },
- // //},
- // //"from": 0,
- // //"size": 1,
- // //"sort": []map[string]interface{}{
- // // {"pubDate": []map[string]interface{}{
- // // {"order": "desc"},
- // // },
- // // },
- // //},
- //}
- //count, err := ChapterLogs.Count(ctx, table, query)
- //if err != nil {
- // logrus.Warnf("Count err:%+v", err)
- // return
- //}
- //
- //logrus.Warnf("Count:%+v", count)
- //
- //res, err := config.Elastic.Cat.Shards(
- // config.Elastic.Cat.Shards.WithContext(ctx),
- //)
- //if err != nil {
- // logrus.Warnf("Shards err:%+v", err)
- // return
- //}
- //
- //shards, err := String(res.Body)
- //if err != nil {
- // logrus.Warnf("Shards String err:%+v", err)
- // return
- //}
- //
- //logrus.Warnf("shards:%+v", shards)
- //
- //ss := strings.Split(shards, "\n")
- //for _, s := range ss {
- // s2 := strings.Split(s, " ")
- // if len(s2) < 1 {
- // continue
- // }
- //
- // if s2[0] != "" {
- // logrus.Warnf("s3:%+v \n", s2[0])
- // }
- //
- // //for k, s3 := range s2 {
- // // if k == 0 {
- // // logrus.Warnf("===================")
- // // }
- // // logrus.Warnf("s3:%+v \n", s3)
- // //}
- //}
- }
- //func AddDoc() {
- //
- // body := &bytes.Buffer{}
- // pubDate := time.Now()
- // json.NewEncoder(body).Encode(&Book{
- // Author: "金庸",
- // Price: 96.0,
- // Name: "天龙八部",
- // Pages: 1978,
- // PubDate: &pubDate,
- // Summary: "...",
- // })
- //
- // // 创建
- // response, err := config.Elastic.Create("es_test_book", "1", body)
- // if err != nil {
- // logrus.Warnf("docs err:%+v", err)
- // }
- //
- // logrus.Warnf("response:%+v", response)
- //}
|