public static IAggregation BucketSort <T>(this IStatAggregation agg, Expression <Func <T, object> > fieldExpression,
                                                  AggsOrderDirection direction, int?size = null, int?from = null)
        {
            var fieldName = ExpressionHelper.GetPropertyName(fieldExpression);

            agg.Aggregations[$"bucket_sort_{fieldName}"] = new BucketSortAggregation
            {
                BucketSort = new BucketSort
                {
                    Size  = size,
                    From  = from,
                    Sorts = new[] { new Sort {
                                        [fieldName] = direction.ToString()
                                    } }
                }
            };
            return(agg);
        }
 public StatsHub(IProcessedIncommingQueue processedIncommingQueue, IRuntimeStatsService runtimeStatsService, IStatAggregation statAggregation)
 {
     _processedIncommingQueue = processedIncommingQueue;
     _runtimeStatsService     = runtimeStatsService;
     _statAggregation         = statAggregation;
 }