Sum Aggregation
POST /sales/_search?size=0
{
"query": {
"constant_score": {
"filter": {
"match": { "type": "hat" }
}
}
},
"aggs": {
"hat_prices": { "sum": { "field": "price" } }
}
}
返回值
{
...
"aggregations": {
"hat_prices": {
"value": 450.0
}
}
}
Missing value
POST /sales/_search?size=0
{
"query": {
"constant_score": {
"filter": {
"match": { "type": "hat" }
}
}
},
"aggs": {
"hat_prices": {
"sum": {
"field": "price",
"missing": 100
}
}
}
}
Histogram fields
PUT metrics_index/_doc/1
{
"network.name" : "net-1",
"latency_histo" : {
"values" : [0.1, 0.2, 0.3, 0.4, 0.5],
"counts" : [3, 7, 23, 12, 6]
}
}
PUT metrics_index/_doc/2
{
"network.name" : "net-2",
"latency_histo" : {
"values" : [0.1, 0.2, 0.3, 0.4, 0.5],
"counts" : [8, 17, 8, 7, 6]
}
}
POST /metrics_index/_search?size=0
{
"aggs" : {
"total_latency" : { "sum" : { "field" : "latency_histo" } }
}
}
返回值
{
...
"aggregations": {
"total_latency": {
"value": 28.8
}
}
}
网友评论