| 常见类型 | derivative / cumulative_sum / moving_fn / bucket_script / bucket_sort |
|---|---|
| 连接方式 | buckets_path 指向同层或上级的聚合名称 |
| 缺口处理 | gap_policy 可选 skip 或 insert_zeros |
示例
示例
GET /sales/_search
{
"size": 0,
"aggs": {
"per_month": {
"date_histogram": { "field": "date", "calendar_interval": "month" },
"aggs": {
"sales": { "sum": { "field": "amount" } },
"sales_diff": { "derivative": { "buckets_path": "sales" } }
}
}
}
}buckets_path 用 > 表示跨层级,如 "agg1>agg2";写错路径会直接报无法解析的聚合名称。