ElasticSearch 学习笔记 - 10.指标聚合
生活随笔
收集整理的這篇文章主要介紹了
ElasticSearch 学习笔记 - 10.指标聚合
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1、基礎數(shù)據(jù)
GET /my-index/_search{"took": 1,"timed_out": false,"_shards": {"total": 5,"successful": 5,"skipped": 0,"failed": 0},"hits": {"total": 2,"max_score": 1,"hits": [{"_index": "my-index","_type": "person","_id": "5","_score": 1,"_source": {"name": "kobe","age": 28,"salary": 10000}},{"_index": "my-index","_type": "person","_id": "6","_score": 1,"_source": {"name": "hadron","age": 19,"salary": 5000}}]} }2、max
GET /my-index/_search {"size": 1,"aggs": {"max_age": {"max": {"field": "age"}}} }{"took": 1,"timed_out": false,"_shards": {"total": 5,"successful": 5,"skipped": 0,"failed": 0},"hits": {"total": 2,"max_score": 1,"hits": [{"_index": "my-index","_type": "person","_id": "5","_score": 1,"_source": {"name": "kobe","age": 28,"salary": 10000}}]},"aggregations": {"max_age": {"value": 28}} }3、min
GET /my-index/_search {"size": 2,"aggs": {"min_age": {"min": {"field": "age"}}} }4、avg
GET /my-index/_search {"size": 2,"aggs": {"avg_age": {"avg": {"field": "age"}}} }5、sum
GET /my-index/_search {"size": 20,"aggs": {"sum_salary": {"sum": {"field": "salary"}}} }6、 stat
GET my-index/_search {"size": 0, "aggs": {"stats_salary": {"stats": {"field": "salary"}}} }{"took": 1,"timed_out": false,"_shards": {"total": 5,"successful": 5,"skipped": 0,"failed": 0},"hits": {"total": 2,"max_score": 0,"hits": []},"aggregations": {"stats_salary": {"count": 2,"min": 5000,"max": 10000,"avg": 7500,"sum": 15000}} }7、高級統(tǒng)計
GET my-index/_search {"size": 0, "aggs": {"stats_salary": {"extended_stats": {"field": "salary"}}} }{"took": 0,"timed_out": false,"_shards": {"total": 5,"successful": 5,"skipped": 0,"failed": 0},"hits": {"total": 2,"max_score": 0,"hits": []},"aggregations": {"stats_salary": {"count": 2,"min": 5000,"max": 10000,"avg": 7500,"sum": 15000,"sum_of_squares": 125000000,"variance": 6250000,"std_deviation": 2500,"std_deviation_bounds": {"upper": 12500,"lower": 2500}}} }8、文檔數(shù)量統(tǒng)計
GET my-index/_search {"size": 0, "aggs": {"doc_count": {"value_count": {"field": "salary"}}} }{"took": 1,"timed_out": false,"_shards": {"total": 5,"successful": 5,"skipped": 0,"failed": 0},"hits": {"total": 3,"max_score": 0,"hits": []},"aggregations": {"doc_count": {"value": 2}} }9、百分位統(tǒng)計
GET my-index/_search {"size": 0, "aggs": {"persion_salary": {"percentiles": {"field": "salary"}}} }{"took": 1,"timed_out": false,"_shards": {"total": 5,"successful": 5,"skipped": 0,"failed": 0},"hits": {"total": 3,"max_score": 0,"hits": []},"aggregations": {"persion_salary": {"values": {"1.0": 5000,"5.0": 5000,"25.0": 5000,"50.0": 7500,"75.0": 10000,"95.0": 10000,"99.0": 10000}}} }總結
以上是生活随笔為你收集整理的ElasticSearch 学习笔记 - 10.指标聚合的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: DialogFragment源码分析
- 下一篇: POJ1741 Tree(树分治——点分