elasticsearch学习(二)之Aggregations(聚合)
来源:互联网 发布:windows to go 教程 编辑:程序博客网 时间:2024/05/19 19:59
基本概念
GROUP BY
但是功能更强大。官方java-api原文
地址:https://www.elastic.co/guide/en/elasticsearch/client/java-api/1.7/java-aggs.html
There are many different types of aggregations, each with its own purpose and output. To better understand these types, it is often easier to break them into two main families:
- Bucketing
- A family of aggregations that build buckets, where each bucket is associated with a key and a document criterion. When the aggregation is executed, all the buckets criteria are evaluated on every document in the context and when a criterion matches, the document is considered to "fall in" the relevant bucket. By the end of the aggregation process, we’ll end up with a list of buckets - each one with a set of documents that "belong" to it.
- Metric
- Aggregations that keep track and compute metrics over a set of documents.
The interesting part comes next. Since each bucket effectively defines a document set (all documents belonging to the bucket), one can potentially associate aggregations on the bucket level, and those will execute within the context of that bucket. This is where the real power of aggregations kicks in:
对应译文
Metric Aggregation(聚合操作)
Percentile Aggregation
Here is an example on how to create the aggregation request:
MetricsAggregationBuilder aggregation = AggregationBuilders .percentiles("agg") .field("height");
You can provide your own percentiles instead of using defaults:
MetricsAggregationBuilder aggregation = AggregationBuilders .percentiles("agg") .field("height") .percentiles(1.0, 5.0, 10.0, 20.0, 30.0, 75.0, 95.0, 99.0);
Use aggregation responseedit
Import Aggregation definition classes:
import org.elasticsearch.search.aggregations.metrics.percentiles.Percentile;import org.elasticsearch.search.aggregations.metrics.percentiles.Percentiles;
// sr is here your SearchResponse objectPercentiles agg = sr.getAggregations().get("agg");// For each entryfor (Percentile entry : agg) { double percent = entry.getPercent(); // Percent double value = entry.getValue(); // Value logger.info("percent [{}], value [{}]", percent, value);}
This will basically produce for the first example:
percent [1.0], value [0.814338896154595]percent [5.0], value [0.8761912455821302]percent [25.0], value [1.173346540141847]percent [50.0], value [1.5432023318692198]percent [75.0], value [1.923915462033674]percent [95.0], value [2.2273644908535335]percent [99.0], value [2.284989339108279]
digest具体可参考文章:https://github.com/tdunning/t-digest/blob/master/docs/t-digest-paper/histo.pdf
"values" : { "1.0": 15, "5.0": 20, "25.0": 23, "50.0": 25, "75.0": 29, "95.0": 60, "99.0": 150 }
- elasticsearch学习(二)之Aggregations(聚合)
- ElasticSearch 的 聚合(Aggregations)
- ElasticSearch 的 聚合(Aggregations)
- ElasticSearch 的 聚合(Aggregations)
- ElasticSearch 的 聚合(Aggregations)
- 实时搜索引擎Elasticsearch(4)——Aggregations (聚合)API的使用
- 实时搜索引擎Elasticsearch(4)——Aggregations (聚合)API的使用
- [Elasticsearch] 聚合作用域(Scoping Aggregations)
- [Elasticsearch] 聚合作用域(Scoping Aggregations) 4
- Elasticsearch java API (16)Aggregations 构建聚合
- Elasticsearch java API (17)Aggregations 聚合 函数
- Elasticsearch java API (18)Aggregations 聚合 Bucket
- Elasticsearch Java API(十一)--聚合(aggregations)
- Elasticsearch 5.x Java api Aggregations(聚合)
- Elasticsearch 5.x Java api Aggregations(聚合)
- elasticsearch-java api之搜索(二)——聚合
- ELK第六篇:Aggregations (聚合)API的使用
- elasticsearch的研究与使用(三)Aggregations
- LDO和DC-DC的区别
- 七个你无法忽视的Git使用技巧
- CSS 颜色代码大全
- Linux 查看磁盘空间
- jQuery学习-选择器
- elasticsearch学习(二)之Aggregations(聚合)
- Web Service和WSDL 概念理解
- 关键帧动画CAKeyframeAnimation
- android selector开发自定义样式实现唯美效果
- java foreach 与 js for/in
- linux java 安装路径
- Codeforces 599D Spongebob and Squares 【公式推导 暴力】
- LIBSVM简介
- eLisp Basics