I have documents that look like this:
{
"clientId": "FPIev_86RwB",
"viewId": "FPIewF1aRyU",
"sessionId": "FPIewE16Rxu",
"trackingId": "FPIewHfaRx9",
"type": "view",
"intVal": [
21,
72,
37
]
}
I want to different aggregations (such as sum or avg) on just one index of the array across a set of documents. However, it seems that I can't specify the index like I could specify a field on an object. Here is what I tried:
{
"size": 0,
"aggs": {
"avg_1": {
"avg": {
"field": "intVal.1"
}
}
}
}
As you can see, I tried selecting the index of the field with intVal.1 but that isn't working. I have a variable number of values that may be added to an array, but the values in a specific index position are all for the same thing so I want to do an aggregation on the array index. Is there any way I can make this work?