Elasticsearch sum_bucket,从结果中剥离中间聚合 [英] Elasticsearch sum_bucket, strip intermediary aggregation from result

查看:110
本文介绍了Elasticsearch sum_bucket,从结果中剥离中间聚合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下查询,其中

  • 我执行第一项聚合,返回大量存储桶
  • 然后在此存储桶上执行指标汇总(此示例中的平均值例子)
  • 最后是sum_bucket聚合

当我运行此查询时,输出包含所有中间my_huge_bucket.my_huge_bucket_metric结果,但我只对sum_bucket指标感兴趣.

When I run this query, the output contains all the intermediary my_huge_bucket.my_huge_bucket_metric results but I am only interested by the sum_bucket metric.

是否可以从结果中剥离中间聚合?

Is there a way to strip the intermediary aggregation from the result?

{
  "size": 0,
  "aggs": {
    "my_sum_bucket": {
      "sum_bucket": {
        "buckets_path": "my_huge_bucket.my_huge_bucket_metric"
      }
    },
    "my_huge_bucket": {
      "terms": {
        "field": "some_field",
        "size": 0
      },
      "aggs": {
        "my_huge_bucket_metric": {
          "avg": {
            "field": "some_field"
          }
        }
      }
    }
  }

}

推荐答案

刚刚发现关于filter_path选项的信息正是我想要的

Just found out about the filter_path options that does exactly what I am looking for

https://www.elastic.co/guide/zh-CN/elasticsearch/reference/2.3/common-options.html#_response_filtering

这篇关于Elasticsearch sum_bucket,从结果中剥离中间聚合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆