使用cate去聚合

1
2
3
4
5
6
7
8
9
10
11
{
"size": 0,
"aggs": {
"group_by_tags": {
"terms": {
"field": "cat",
"size": 50
}
}
}
}
1
2
3
4
5
6
7
8
9
10
{
"size": 0,
"aggs": {
"sum_monthly_bs_total": {
"sum": {
"field": "total_fans"
}
}
}
}

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
46
47
48
{
"query": {
"bool": {
"must": [
{
"term": {
"is_mcn": 0
}
},
{
"term": {
"event_day": 20221111
}
}
]
}
},
"aggs": {
"all_is_active": {
"sum": {
"field": "all_is_active"
}
},
"all_is_active_month": {
"sum": {
"field": "all_is_active_month"
}
},
"all_author_distribution_avg": {
"sum": {
"script": {
"lang": "painless",
"source": "doc['all_author_distribution_avg'].value<1000? 1: 0"
}
}
},
"all_author_distribution_avg2": {
"sum": {
"script": {
"lang": "painless",
"source": "doc['all_author_distribution_avg'].value>8000? 1: 0"
}
}
}
},
"size": 0,
"track_total_hits": true
}