# Accessing extended stats bucket in sibling aggregation

**URL:** <https://discuss.elastic.co/t/accessing-extended-stats-bucket-in-sibling-aggregation/206395>\
**Category:** Elasticsearch\
**Created:** [November 4, 2019, 12:15pm UTC](https://discuss.elastic.co/t/accessing-extended-stats-bucket-in-sibling-aggregation/206395 "2019-11-04T12:15:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcampster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mcampster/32/15304_2.png) [@mcampster](https://discuss.elastic.co/u/mcampster)\
**Post date:** [November 4, 2019, 12:15pm UTC](https://discuss.elastic.co/t/accessing-extended-stats-bucket-in-sibling-aggregation/206395/1 "2019-11-04T12:15:13Z")

</div>

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?

```auto
{
  "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" 
          } 
        } 
      } 
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 2, 2019, 12:15pm UTC](https://discuss.elastic.co/t/accessing-extended-stats-bucket-in-sibling-aggregation/206395/2 "2019-12-02T12:15:20Z")

</div>

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