#年龄段统计
GET /索引/_search
{
"size": 0,
"query": {
"bool": {
"filter": [{
"bool": {
"must": {
"exists": {
"field": "birthday"
}
}
}
}
]
}
},
"aggs": {
"popular_age": {
"range": {
"field": "birthday",
"format": "yyyy-MM-dd",
"ranges": [
{
"from": "now-10y",
"to": "now-20y"
},
{
"from": "now-20y",
"to": "now-30y"
},
{
"from": "now-30y",
"to": "now-40y"
},
{
"from": "now-40y",
"to": "now-50y"
},
{
"from": "now-50y",
"to": "now-60y"
},
{
"from": "now-60y",
"to": "now-70y"
},
{
"from": "now-70y",
"to": "now-80y"
},
{
"from": "now-80y"
}
]
}
}
}
}
elasticsearch根据出生日期 yyyy-MM-dd统计年龄
最新推荐文章于 2023-09-04 00:03:04 发布