ElasticSearch格式化管道聚合结果
2017-03-09 11:50
218 查看
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:
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
format参数的值:
还有其他的可取值,可参考:
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 |
"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)); } }
相关文章推荐
- elasticsearch 查询聚合结果排序
- Elasticsearch里面聚合group结果不正确
- elasticsearch聚合操作——本质就是针对搜索后的结果使用桶bucket(允许嵌套)进行group by,统计下分组结果,包括min/max/avg
- elasticsearch核心知识--30.分页搜索以及deep paging性能问题深度理解和es中聚合aggregation的分组可能结果不准确的原因
- elasticsearch选择器聚合,分组返回聚合结果
- Elasticsearch聚合初探——metric篇
- Elasticsearch强大的聚合功能Facet
- Powershell过滤管道结果
- C#格式化数值结果表
- essql聚合结果封装处理
- 009-elasticsearch【三】示例数据导入、URI查询方式简介、Query DSL简介、查询简述【_source、match、must、should等】、过滤器、聚合
- oracle SQL 如何显示group by 聚合结果count 为0的查询
- elasticsearch如何获得查询的全部结果
- Elasticsearch聚合查询
- ElasticSearch查看分词结果
- MongoDB命令行模式下,格式化find()的返回结果,pretty()
- elasticsearch 多次聚合
- Elasticsearch5.3 JAVA Demo 聚合查询
- c++ 使用管道获取CMD命令结果
- saltstack执行结果结合Elasticsearch来展现