在sum aggregation,进行过滤

Bucket Selector Aggregation

Note: The bucket_selector aggregation, like all pipeline aggregations, executions after all other sibling aggregations. This means that using the bucket_selector aggregation to filter the returned buckets in the response does not save on execution time running the aggregations.
对sum的结果进行过滤

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
GET stat/service/_search
{
"query": {
"bool": {
"must": [
{"range": {
"start": {
"gte": 1505975853000
}
}
},
{
"range": {
"end": {
"lte": 1506062253000
}
}
}
]
}
},
"aggs": {
"sd": {
"terms": {
"field": "service",
"size": 10
},
"aggs": {
"ds": {
"sum": {
"field": "times"
}
},
"sales_bucket_filter": {
"bucket_selector": {
"buckets_path": {
"totalSales": "ds"
},
"script": "params.totalSales > 1"
}
}
}
}
}
}

Date Histogram Aggregation
Dates are represented in elasticsearch internally as long values.