我需要在查询中按天分组,所以我尝试使用日期时间字段应用分组,如下所示:
{
"_source": "false",
"query": {
"match_all": {}
},
"aggs": {
"group_by_weekday": {
"date_histogram": {
"field": "record_created_at",
"calendar_interval": "day",
"format": "EEEE"
}
}
}
}
但是我得到的结果如下?
{
"aggregations": {
"group_by_weekday": {
"buckets": [
{
"key_as_string": "Tuesday",
"key": 1682380800000,
"doc_count": 13
},
{
"key_as_string": "Wednesday",
"key": 1682467200000,
"doc_count": 0
},
{
"key_as_string": "Thursday",
"key": 1682553600000,
"doc_count": 1
},
{
"key_as_string": "Wednesday",
"key": 1683072000000,
"doc_count": 1
},
{
"key_as_string": "Thursday",
"key": 1683158400000,
"doc_count": 1
}
]
}
}
}
这里似乎没有应用分组
我们怎样才能用其他方法来克服这个问题?