docs: def get_agg(cls, field=None, date_field=None, start=None, end=None,
                  filters={}, agg_type="terms", offset=None, interval=None):
          """
          Compute the aggregated value for a field.
          :param field: field to get the time series values
          :param date_field: field with the date
          :param interval: interval to be used to generate the time series values, such as:(year(y),
                           quarter(q), month(M), week(w), day(d), hour(h), minute(m), second(s))
          :param start: date from for the time series, should be a datetime.datetime object
          :param end: date to for the time series, should be a datetime.datetime object
          :param agg_type: kind of aggregation for the field (cardinality, avg, percentiles)
          :param offset: offset to be added to the time_field in days
          :return: a query containing the aggregation, filters and range for the specified term
          """
          # This gives us the basic structure of the query, including:
          # Normal and inverse filters and range.
          s = cls.__get_query_basic(date_field=date_field, start=start, end=end, filters=filters)
  
          # Get only the aggs not the hits
          # Default count starts from 0
          s = s.extra(size=0)
  
          if agg_type == "count":
              agg_type = 'cardinality'
          elif agg_type == "median":
              agg_type = 'percentiles'
          elif agg_type == "average":
              agg_type = 'avg'
  
          if not interval:
              if agg_type == "terms":
                  agg_id, query_agg = ElasticQuery.__get_query_agg_terms(field)
              elif agg_type == "max":
                  agg_id, query_agg = ElasticQuery.__get_query_agg_max(field)
              elif agg_type == "cardinality":
                  agg_id, query_agg = ElasticQuery.__get_query_agg_cardinality(field)
              elif agg_type == "percentiles":
                  agg_id, query_agg = ElasticQuery.__get_query_agg_percentiles(field)
              elif agg_type == "avg":
                  agg_id, query_agg = ElasticQuery.__get_query_agg_avg(field)
              else:
                  raise RuntimeError("Aggregation of %s not supported" % agg_type)
          else:
              agg_id, query_agg = ElasticQuery.__get_query_agg_ts(field, date_field,
                                                                  start=start, end=end,
                                                                  interval=interval,
                                                                  agg_type=agg_type,
                                                                  offset=offset)
          s.aggs.bucket(agg_id, query_agg)
  
          return s.to_dict()