ES脚本笔记

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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#脚本查type非数字的粉丝数
POST /weibo_interest_push_material_alias/_search
{
"track_total_hits": true,
"query": {
"bool": {
"must": [
{
"query_string": {
"default_field": "FIELD",
"query": """
+features.static_features.user_fans_num:[* TO *]
+features.static_features.text_length:[140 TO *]
-features.static_features.has_link: 1
-content_tag.tag_name:财经
-_exists_:filter_rules.content_rules.keyword
"""
}
},
{
"script": {
"script": """
def my_val = Integer.parseInt(doc['features.static_features.user_fans_num.keyword'].value);
if(my_val>=0&&my_val<1000)
return true;else return false;
"""
}
}
]
}
},
"aggs": {
"day": {
"terms": {
"field": "kibana_info.store_at_day.keyword",
"size": 1000
}
}
},
"size": 1000
}

#聚合查点赞数
GET /weibo_interest_push_material_alias/_search
{
"query": {
"bool": {
"must": [
{"range": {
"features.static_features.text_length": {
"gte": 140
}
}},
{"range": {"kibana_info.store_at_day": {"gte": 20210805,"lt":20210905}}},
{"range": {"features.static_features.hot_his_like": {"gte": 1,"lt":1000}}}
],
"must_not": [
{"term": {
"features.static_features.has_link": {
"value": 1
}
}},
{"terms": {
"content_tag.tag_name": [
"财经"
]
}},
{"exists": {"field": "filter_rules.content_rules.keyword"}}


]
}
},

"aggs": {
"day": {
"terms": {
"field": "kibana_info.store_at_day.keyword",
"size": 1000
}
}

},
"size": 0
}