Accessing extended stats bucket in sibling aggregation

I am trying to access the lower and upper thresholds from the extended_stats_bucket in another aggregation but not having any joy. (Elastic 5.4). What am I doing wrong?

{
  "size": 0,
  "aggs": {
    "byWeeklyDocCount": {
      "date_histogram": {
        "field": "createdTimeStamp",
        "interval": "week"
      }
    },
    "statsOfWeeklyDocCount": {
      "extended_stats_bucket": {
        "buckets_path": "byWeeklyDocCount>_count",
        "sigma": 3
      }
    },
    "byWeeklyAggregation": { 
      "date_histogram": { 
        "field": "createdTimeStamp", 
        "interval": "week" 
      }, 
      "aggs": { 
        "outlierSelector": { 
          "bucket_selector": { 
            "buckets_path": {
              "doc_count": "_count",
              "min_threshold": "statsOfWeeklyDocCount.std_lower",
              "max_threshold": "statsOfWeeklyDocCount.std_upper"
            }, 
            "script": "params.doc_count < params.min_threshold || params.doc_count > params.max_threshold" 
          } 
        } 
      } 
    }
  }
}

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