Pick latest child records of each parent and aggregate data

Hi Rajesh,
If I read the question correctly you're trying to do aggregations on the last-known-state of all the parents.
That's tough to do at scale because while you may have only 3 states in your results (NOACTION / REVOKED / CERTIFIED) you have potentially many parents to consider along the way. Each of the parent IDs will need loading into memory and have their last state derived. I expect this is all possible using a scripted aggregation but it may have memory issues.

How many parents do you expect to have?
If it's too many you may need to update parents with their last known state at index time