This topic has been discussed over the years with no actual confirmed solution. The most prominent thread about this topic: https://stackoverflow.com/questions/36505459/insert-aggregation-results-into-an-index?rq=1 stated some solutions such as using Watcher and the Exec Input Plugin that seems to be able to work but I have not tried them myself yet.
Right now I'm using the Elasticsearch Input plugin to execute the aggregation query and Elasticsearch Output plugin to push the results into the index. However this is not working as the input plugin is unable to handle any aggregation calculations. Has anyone tried out the 2 methods above and are there any other possible solutions to accomplish this goal? Thanks!