Terms Aggregation: auto-number the buckets in a sub-aggregation with script


(drjz) #1

I am wondering whether it is possible to use a sub-aggregation to automatically number the buckets retrieved. Basically, I want to incrementally count the buckets.

So:

{
"key" : "8130837",
"doc_count" : 1,
"bucketOrder" : {
  "value" : 1.0
 }
}, {
"key" : "8131106",
"doc_count" : 1,
"bucketOrder" : {
  "value" : 2.0
 }
}, {
"key" : "8131131",
"doc_count" : 1,
"bucketOrder" : {
  "value" : 3.0
 }
}

The reason why I want this incremental count, is so that I can use this in a script filter.


(system) #2