1. 程式人生 > 實用技巧 >es聚合查詢語法

es聚合查詢語法

{
"size": 0,
"query": {
"bool": {
"filter": [
{
"range": {
"@timestamp": {
"gte": 1596572166943,
"lte": 1596593766943,
"format": "epoch_millis"
}
}
},
{
"query_string": {
"analyze_wildcard": true,
"query": "hostname:localhost OR test"
}
}
]
}
},
"aggs": {
"2": {
"date_histogram": {
"interval": "30s",
"field": "@timestamp",
"min_doc_count": 0,
"extended_bounds": {
"min": 1596572166943,
"max": 1596593766943
},
"format": "epoch_millis"
},
"aggs": {
"1": {
"avg": {
"field": "mainunit.flow_count"
}
}
}
}
}
}

size表示查詢結果中顯示多少條原始語句