Use result of an aggregation query to enrich doc

Is its possible to execute an aggregation query on an index and use the results in one action to enrich the same index/documents with it.

Assume i have serveral document with field region, sensor type sensor. I want to add to each document the number of times the sensor triggered, the number of times it was a certain sensor type and how many times it happend in a region. The aggregation of counting the values are in time frames of 5min.

It's looking a bit similar to what downsampling does: Downsampling a time series data stream | Elasticsearch Guide [8.14] | Elastic

But to answer your exact question, no I don't think you can inside Elasticsearch do that automatically. But you can write a piece of code which does that I guess. Or look at downsampling to see if it helps.