日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

通過(guò)Transforms處理和分析數(shù)據(jù)

Elasticsearch的Transforms功能是一種數(shù)據(jù)處理和分析工具,用于對(duì)數(shù)據(jù)進(jìn)行預(yù)處理、聚合和轉(zhuǎn)換等操作,Transforms功能可以在不影響原始數(shù)據(jù)的情況下,對(duì)數(shù)據(jù)進(jìn)行加工處理,更好地滿足數(shù)據(jù)分析和可視化的需求。本文通過(guò)Transforms功能對(duì)投籃數(shù)據(jù)進(jìn)行轉(zhuǎn)換,并查看轉(zhuǎn)換后的數(shù)據(jù)。

準(zhǔn)備工作

  1. 下載樣例數(shù)據(jù)。本文使用Kaggle上的數(shù)據(jù)集NBA shot logs,該數(shù)據(jù)集中包含投籃時(shí)間、投籃者、投籃點(diǎn)、最近的防守球員、最近的防守球員距離投籃者的距離等投籃數(shù)據(jù)。下載地址,請(qǐng)參見(jiàn)shot_logs.csv。

  2. 創(chuàng)建阿里云Elasticsearch實(shí)例。具體操作,請(qǐng)參見(jiàn)創(chuàng)建阿里云Elasticsearch實(shí)例。本文使用7.10.0版本Elasticsearch實(shí)例。

    說(shuō)明

    暫不支持8.5版本Elasticsearch實(shí)例。

  3. 登錄Kibana控制臺(tái)。具體操作,請(qǐng)參見(jiàn)登錄Kibana控制臺(tái)

  4. 導(dǎo)入數(shù)據(jù)nba_short_logs,并創(chuàng)建索引。

    1. 在Kibana頁(yè)面的左上角,選擇菜單.png > Kibana > Machine Learning 。

    2. 單擊Data Visualizer頁(yè)簽。

    3. Import data區(qū)域,單擊Upload file

    4. 單擊image.png圖標(biāo)。

    5. 選擇shot_logs文件。

    6. 在頁(yè)面右下角,單擊Import。

    7. Simple頁(yè)簽下,輸入Index name(索引名稱)為nba_short_logs,選中Create index pattern(創(chuàng)建索引)。

    8. 單擊Import。

      數(shù)據(jù)導(dǎo)入成功后的界面如下圖所示。

      image.png

操作步驟

本文通過(guò)三種方式實(shí)現(xiàn)數(shù)據(jù)的轉(zhuǎn)換和查看。

方法一:通過(guò)Kibana創(chuàng)建轉(zhuǎn)換并查看數(shù)據(jù)

  1. 在Kibana頁(yè)面的左上角,選擇菜單.png > Management > Stack Management

  2. 在左側(cè)菜單欄,單擊Data > Transforms。

  3. 單擊Create your first transform。

  4. 選擇nba_short_logs索引。

  5. Configuration區(qū)域,Group by選擇histogram(GAME_ID),Aggregations選擇DRIBBLES.sum、DRIBBLES.avg和DRIBBLES.max。

    image.png
    說(shuō)明
    • Group by GAME_ID:按比賽ID進(jìn)行分組。

    • DRIBBLES.sum:每場(chǎng)比賽中所有球員運(yùn)球的總次數(shù)。

    • DRIBBLES.avg:每場(chǎng)比賽中每個(gè)球員的平均運(yùn)球次數(shù)。

    • DRIBBLES.max:每場(chǎng)比賽中運(yùn)球次數(shù)最多的球員的運(yùn)球次數(shù)。

  6. Configuration區(qū)域右下角,單擊Next

  7. Transform details區(qū)域,填寫(xiě)Transform ID和Destination index(目的地索引),然后在頁(yè)面右側(cè)單擊Next

  8. Create區(qū)域,單擊Create and start

    說(shuō)明

    Progress的進(jìn)度條變?yōu)?00%,表示創(chuàng)建完成。

  9. 單擊Discover,查看Destination index數(shù)據(jù)。

    image.png

方法二:通過(guò)API創(chuàng)建轉(zhuǎn)換并查看數(shù)據(jù)

  1. 在Kibana頁(yè)面的左上角,選擇菜單.png > Management > Dev Tools 。

    1. Console頁(yè)簽中,執(zhí)行以下命令,通過(guò)transform創(chuàng)建轉(zhuǎn)換。

      PUT _transform/test2_nba_shot_logs
      {
          "source": {
          "index": "nba_short_logs"
        },
        "dest" : { 
          "index" : "test2_nba_short_logs"
        },
        "pivot": {
          "group_by": { 
            "game_id": { "terms": { "field": "GAME_ID" }}
          },
          "aggregations": {
            "dribbles_sum": { "sum": { "field": "DRIBBLES" }},
            "dribbles_avg": { "avg": { "field": "DRIBBLES" }},
            "dribbles_max": { "cardinality": { "field": "DRIBBLES" }}
          }
        }
      }
    2. 執(zhí)行以下命令,通過(guò)preview查看轉(zhuǎn)換后的數(shù)據(jù)。

      POST _transform/_preview
      {
        "source": {
          "index": "nba_shot_logs"
        },
        "dest" : { 
          "index" : "test2_nba_shot_logs"
        },
        "pivot": {
          "group_by": { 
            "game_id": { "terms": { "field": "GAME_ID" }}
          },
          "aggregations": {
            "dribbles_sum": { "sum": { "field": "DRIBBLES" }},
            "dribbles_avg": { "avg": { "field": "DRIBBLES" }},
            "dribbles_max": { "cardinality": { "field": "DRIBBLES" }}
          }
        }
      }

方法三:通過(guò)API創(chuàng)建轉(zhuǎn)換并通過(guò)Discover查看數(shù)據(jù)

  1. 創(chuàng)建并啟動(dòng)Transform。

    1. 在Kibana頁(yè)面的左上角,選擇菜單.png > Management > Dev Tools 。

    2. Console頁(yè)簽中,執(zhí)行以下命令,創(chuàng)建Transform。

      PUT _transform/test2_nba_shot_logs
      {
          "source": {
          "index": "nba_short_logs"
        },
        "dest" : { 
          "index" : "test2_nba_short_logs"
        },
        "pivot": {
          "group_by": { 
            "game_id": { "terms": { "field": "GAME_ID" }}
          },
          "aggregations": {
            "dribbles_sum": { "sum": { "field": "DRIBBLES" }},
            "dribbles_avg": { "avg": { "field": "DRIBBLES" }},
            "dribbles_max": { "cardinality": { "field": "DRIBBLES" }}
          }
        }
      }
    3. 啟動(dòng)Transform。

      POST _transform/test2_nba_shot_logs/_start
      說(shuō)明

      Transform默認(rèn)是關(guān)閉的。

  2. 創(chuàng)建索引模式。

    說(shuō)明

    在Discover中查看數(shù)據(jù)之前需要先創(chuàng)建索引模式。

    1. 在Kibana頁(yè)面的左上角,選擇菜單.png > Management > Stack Management 。

    2. 在左側(cè)菜單欄,單擊Kibana > Index Patterns。

    3. 在頁(yè)面右上角,單擊Create index pattern。

    4. Index pattern name中輸入轉(zhuǎn)換后的目標(biāo)索引,即test2_nba_short_logs,單擊Next step。

    5. 單擊Create index pattern

  3. 通過(guò)Discover查看數(shù)據(jù)。

    1. 在Kibana頁(yè)面的左上角,選擇菜單.png > Kibana > Discover 。

    2. 選擇轉(zhuǎn)換后的目標(biāo)索引,查看轉(zhuǎn)換后的數(shù)據(jù)。