High cardinality下对持续写入的Elasticsearch索引进行聚合查询的性能优化

2021-12-28 00:00:00 索引 查询 函数 写入 小时

High cardinality下对持续写入的Elasticsearch索引进行聚合查询的性能优化

背景

近使用腾讯云Elasticsearch Service的用户提出,对线上的ES集群进行查询,响应越来越慢,希望能帮忙优化一下。
查询越来越慢的语句如下:

{
"_source": false,
"size": ,
"aggs": {
"traceId": {
"aggs": {
"timestamp_millis": {
"min": {
"field": "timestamp_millis"
}
}
},
"terms": {
"field": "traceId",
"order": {
"timestamp_millis": "desc"
},
"size": 10
}
}
},
"query": {
"bool": {
"filter": {
"bool": {
"must": [
{
"range": {
"timestamp_millis": {
"from": 1556431798000,
"include_lower": true,
"include_upper": true,
"to": 1556435398000
}
}
},
{
"term": {
"user": "1275813850"
}
}
]
}
}
}
}
}


相关文章