elasticsearch_dsl使用

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
POST /_search
{
"size": 0,
"aggs": {
"by_grp" : {
"terms": {
"field": "grpId",
"size": 0
},
"aggs": {
"twitter_count": {
"range": {
"field": "twitter.followers",
"ranges": [
{ "to" : 501},
{ "from" : 501, "to" : 1001},
{ "from" : 1001, "to" : 5001},
{ "from" : 5001}
]
},
"aggs" : {
"email_addy": {
"terms" : {
"field": "email.value",
"size": 0
}
}
}
}
}
}
}
}
1
2
3
4
5
6
7
8
9
10
s.aggs.bucket('by_grp', 'terms', field='grpId', size=0) \
.bucket('twitter_count', 'range', field='twitter.followers',
ranges=[
{'to': 5001},
{'from': 5001, 'to': 10001},
{'from': 10001, 'to': 50001},
{'from': 50001}
]
) \
.bucket('email_addy', 'terms', field='email.value', size=0)
坚持原创技术分享,您的支持将鼓励我继续创作!