Accessing lower bound of extended stats bucket

Is it possible to access the lower bound of an extended stats bucket through the buckets path of a bucket script? If so, how can this be done?

GET someIndex/_search
{
"size": 0,
"aggs": {
"bySomeField": {
"terms": {
"field": "someProperty"
},
"aggs": {
"byWeeklyInterval": {
"date_histogram": {
"field": "someDateProperty",
"interval": "week"
}
},
"extendedStats": {
"extended_stats_bucket": {
"buckets_path": "byWeeklyInterval>_count"
}
},
"deviant": {
"bucket_script": {
"buckets_path": {
"lowerBound": "extendedStats.std_deviation_bounds[lower]"
},
"script": "lowerBound"
}
}
}
}
}
}

I've read tried several options of the section buckets path syntax, like:

  • extendedStats.std_deviation_bounds[lower]
    • "type": "illegal_argument_exception"
    • "reason": "No aggregation found for path [extendedStats.std_deviation_bounds[lower]]"
  • extendedStats.std_deviation_bounds.lower
    • "type": "illegal_argument_exception"
    • "reason": "No aggregation found for path [extendedStats.std_deviation_bounds.lower]"
  • extendedStats>std_deviation_bounds.lower
    • "type": "illegal_argument_exception"
    • "reason": "path not supported for [extendedStats]: [std_deviation_bounds, lower]"
  • extendedStats>std_deviation_bounds[lower]
    • "type": "illegal_argument_exception"
    • "reason": "path not supported for [extendedStats]: [std_deviation_bounds, lower]"
  • extendedStats[std_deviation_bounds][lower]
    • "type": "illegal_argument_exception"
    • "reason": "No aggregation found for path [extendedStats[std_deviation_bounds][lower]]"
  • extendedStats[std_deviation_bounds[lower]]
    • "type": "illegal_argument_exception"
    • "reason": "No aggregation found for path [extendedStats[std_deviation_bounds[lower]]]"

Unfortunately none of them seem to be working.

Looks like the bucketsPath you want is extendedStats.std_lower which is really not the most obvious thing in the world.

I have raised the following issue to address this in future versions: https://github.com/elastic/elasticsearch/issues/19040

2 Likes