오락기/ELK

elasticsearch aggregation

문방구앞오락기 2018. 5. 11. 15:52

수학적인 평균 최소 최대  구할수잇는 함수 

 

{ 

 

 

"size" : 0, 

 

"aggs" : { 

 

"avg_score" : { 

 

"avg" : { 

 

"field" : "points" 

 

} 

 

} 

 

} 

 

} 

 

json으로 만들고 

 

[js@localhost elasticsearch]$ curl -XGET localhost:9200/_search?pretty -H 'Content-Type:application/json' --data-binary @avg_points_aggs.json 

{ 

  "took" : 314, 

  "timed_out" : false, 

  "_shards" : { 

    "total" : 16, 

    "successful" : 16, 

    "skipped" : 0, 

    "failed" : 0 

  }, 

  "hits" : { 

    "total" : 31, 

    "max_score" : 0.0, 

    "hits" : [ ] 

  }, 

  "aggregations" : { 

    "avg_score" : { 

      "value" : 25.0 

    } 

  } 

} 

 

 

평균값을 구할수있다. 

 

이처럼 max min 기타 등등 구할  있다.