Takes in an es_dsl Aggregation object and adds it to the aggregation dict.
        Can be used to add custom aggregations such as moving averages

        :param agg: aggregation to be added to the es_dsl search object
        :param name: name of the aggregation object (optional)
        :returns: self, which allows the method to be chainable with the other methods

def add_custom_aggregation(self, agg, name=None):
        """
        Takes in an es_dsl Aggregation object and adds it to the aggregation dict.
        Can be used to add custom aggregations such as moving averages

        :param agg: aggregation to be added to the es_dsl search object
        :param name: name of the aggregation object (optional)
        :returns: self, which allows the method to be chainable with the other methods
        """

        agg_name = name if name else 'custom_agg'
        self.aggregations[agg_name] = agg
        return self