How can i access nested docs in scripted_metric after nested aggregation?
I make request
{
"query": {
"match_all": {}
},
"aggs": {
"q1": {
"nested": {
"path": "pp"
},
"aggs": {
"q2": {
"scripted_metric": {
"init_script": "state.transactions = []",
"map_script": "state.transactions.add(doc['pp.id'])",
"combine_script": "return state.transactions",
"reduce_script": "return states"
}
}
}
}
}
}
This is just example, in more complex query i will add filter
aggs to filter nested docs. And then i will process only matched nested docs.
I would like to process in map_script all nested docs that current level of aggs use. But doc['pp.id']
returns only value of one nested doc from row. And any other i try returns error - doc['pp[0].id']
or for (item in doc['pp'])