Pipeline aggs with more than one level depth

Hi everyone,
I'm trying to make an avg_bucket agg that goes more than one level deep like this

...
  "aggs": {
    "group_by_implementation_waiting": {
      "terms": {
        "field": "implementation.keyword",
        "size": 100000,
        "order": {
          "_key": "asc"
        }
      },
      "aggs": {
        "group_by_date": {
          "date_histogram": {
            "field": "emission_date",
            "fixed_interval": "1d",
            "min_doc_count": 1
          },
          "aggs": {
            "group_by_section": {
              "terms": {
                "field": "event.data.section.keyword",
                "size": 100000,
                "order": {
                  "_key": "asc"
                }
              },
              "aggs": {
                "group_by_identifier_waiting": {
                  "terms": {
                    "field": "identifier.keyword",
                    "size": 1000000
                  },
                  "aggs": {
                    "max_date": {
                      "max": {
                        "field": "event.date"
                      }
                    },
                    "min_date": {
                      "min": {
                        "field": "event.date"
                      }
                    },
                    "datediff": {
                      "bucket_script": {
                        "buckets_path": {
                          "start_date": "min_date",
                          "end_date": "max_date"
                        },
                        "script": "(params.end_date - params.start_date)/1000"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "implementation_waiting_avg": {
      "avg_bucket": {
        "buckets_path": "group_by_implementation_waiting>group_by_date>group_by_section>group_by_identifier_waiting>datediff"
      }
    }
  }
}

but i'm getting an "buckets_path must reference either a number value or a single value numeric metric aggregation, got: [Object[]] at aggregation [group_by_date]" and I DO understand why this is happening, I've seen the issue (here and here for example) but I want't to know if there is an easier and less expensive way to solve it than creating a bucket for each agg level or there is a way of reference a more than one level depp bucket.
Either way, why isn't my buckets_path possible? Is it not reasonable? It seems to me.
Thank you all.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.