def aggregate(self, *args, **kwargs):
obj = self._clone()<EOL>obj._facets = [] <EOL>from django.db.models import Avg, Max, Min<EOL>for arg in args:<EOL><INDENT>if isinstance(arg, (Avg, Max, Min)):<EOL><INDENT>field, djfield = self._django_to_es_field(arg.lookup)<EOL>if not djfield:<EOL><INDENT>obj = obj.annotate(field)<EOL><DEDENT>from pyes.facets import StatisticalFacet<EOL>obj = obj.annotate(StatisticalFacet(field, field))<EOL><DEDENT><DEDENT>facets = obj.get_facets()<EOL>result = {}<EOL>for name, values in facets.items():<EOL><INDENT>for k, v in values.items():<EOL><INDENT>if k.startswith("<STR_LIT:_>"):<EOL><INDENT>continue<EOL><DEDENT>result[u'<STR_LIT>' % (name, k)] = v<EOL><DEDENT><DEDENT>return result<EOL>
Returns a dictionary containing the calculations (aggregation)
over the current queryset

If args is present the expression is passed as a kwarg using
the Aggregate object's default alias.