gpt4 book ai didi

elasticsearch - 将查询与日期直方图结合

转载 作者:行者123 更新时间:2023-12-02 23:15:13 25 4
gpt4 key购买 nike

我想计算最近一小时的文档数量,并将其汇总到5分钟的存储桶中。
这是我的查询:


GET logs-tsi-2019.05/tsi-json-log/_search
{
"query": {
"bool": {
"must": [
{
"range": {
"@timestamp": {
"gte": "now-1h",
"lt": "now"
}
}
},
{
"term" : {
"application" : "sso"
}
},
{
"query_string": {
"default_field": "*",
"query": "grant_type=refresh_token",
"analyze_wildcard": true
}
}
]
}
}
}

如何将此查询与date_histogram聚合结合使用?

问候,
克里斯

最佳答案

好的开始!您可以这样做:

GET logs-tsi-2019.05/tsi-json-log/_search
{
"query": {
"bool": {
"must": [
{
"range": {
"@timestamp": {
"gte": "now-1h",
"lt": "now"
}
}
},
{
"term" : {
"application" : "sso"
}
},
{
"query_string": {
"default_field": "*",
"query": "grant_type=refresh_token",
"analyze_wildcard": true
}
}
]
}
},
"aggs": {
"5min": {
"date_histogram": {
"field": "@timestamp",
"interval": "5m"
}
}
}
}

关于elasticsearch - 将查询与日期直方图结合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56170368/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com