欢迎投稿

今日深度:

ElasticSearch格式化管道聚合结果,elasticsearch管道

ElasticSearch格式化管道聚合结果,elasticsearch管道


Bucket Script Aggregationedit
Warning
This functionality is experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.

A parent pipeline aggregation which executes a script which can perform per bucket computations on specified metrics in the parent multi-bucket aggregation. The specified metric must be numeric and the script must return a numeric value.

Syntaxedit
A bucket_script aggregation looks like this in isolation:

{
    "bucket_script": {
        "buckets_path": {
            "my_var1": "the_sum", 
            "my_var2": "the_value_count"
        },
        "script": "my_var1 / my_var2"
    }
}

Here, my_var1 is the name of the variable for this buckets path to use in the script, the_sum is the path to the metrics to use for that variable.

Table 11. bucket_script Parameters
Parameter Name

Description Required Default Value
script The script to run for this aggregation. The script can be inline, file or indexed. (see Scripting for more details) Required
buckets_path A map of script variables and their associated path to the buckets we wish to use for the variable (see the section called “buckets_path Syntaxedit” for more details) Required
gap_policy The policy to apply when gaps are found in the data (see the section called “Dealing with gaps in the dataedit” for more details) Optional, defaults to skip
format format to apply to the output value of this aggregation Optional, defaults to null

format参数的值:

 "hit/traffic" : {
              "bucket_script" : {
                "script" : {
                  "inline" : "hit/traffic"
                },
                "format" : "#.##",
                "buckets_path" : {
                  "traffic" : "_count",
                  "hit" : "hit>_count"
                }
              }
            }

还有其他的可取值,可参考:

importjava.text.DecimalFormat;  
    
publicclassTestNumberFormat{  
    
  publicstaticvoidmain(String[]args){  
    doublepi=3.1415927; //圆周率  
    //取一位整数  
    System.out.println(newDecimalFormat("0").format(pi));   //3  
    //取一位整数和两位小数  
    System.out.println(newDecimalFormat("0.00").format(pi)); //3.14  
    //取两位整数和三位小数,整数不足部分以0填补。  
    System.out.println(new DecimalFormat("00.000").format(pi));// 03.142  
    //取所有整数部分  
    System.out.println(newDecimalFormat("#").format(pi));   //3  
    //以百分比方式计数,并取两位小数  
    System.out.println(new DecimalFormat("#.##%").format(pi)); //314.16%  
    
    longc=299792458;  //光速  
    //显示为科学计数法,并取五位小数  
    System.out.println(newDecimalFormat("#.#####E0").format(c)); //2.99792E8  
    //显示为两位整数的科学计数法,并取四位小数  
    System.out.println(newDecimalFormat("00.####E0").format(c)); //29.9792E7  
    //每三位以逗号进行分隔。  
    System.out.println(newDecimalFormat(",###").format(c));   //299,792,458  
    //将格式嵌入文本  
    System.out.println(newDecimalFormat("光速大小为每秒,###米。").format(c));  
  }  
}  

www.htsjk.Com true http://www.htsjk.com/Elasticsearch/30268.html NewsArticle ElasticSearch格式化管道聚合结果,elasticsearch管道 Bucket Script Aggregationedit Warning This functionality is experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach t...
相关文章
    暂无相关文章
评论暂时关闭