Class Accumulators


  • public final class Accumulators
    extends 
    Builders for accumulators used in the group pipeline stage of an aggregation pipeline.
    Since:
    3.1
    MongoDB documentation
    Since server release
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <TExpression>
      BsonField
       fieldName, TExpression expression)
      Gets a field name for a $group operation representing all unique values that results from applying the given expression to each document in a group of documents that share the same group by key.
      static <TExpression>
      BsonField
       fieldName, TExpression expression)
      Gets a field name for a $group operation representing the average of the values of the given expression when applied to all members of the group.
      static <TExpression>
      BsonField
       fieldName, TExpression expression)
      Gets a field name for a $group operation representing the value of the given expression when applied to the first member of the group.
      static <TExpression>
      BsonField
       fieldName, TExpression expression)
      Gets a field name for a $group operation representing the value of the given expression when applied to the last member of the group.
      static <TExpression>
      BsonField
       fieldName, TExpression expression)
      Gets a field name for a $group operation representing the maximum of the values of the given expression when applied to all members of the group.
      static <TExpression>
      BsonField
       fieldName, TExpression expression)
      Gets a field name for a $group operation representing the minimum of the values of the given expression when applied to all members of the group.
      static <TExpression>
      BsonField
       fieldName, TExpression expression)
      Gets a field name for a $group operation representing an array of all values that results from applying an expression to each document in a group of documents that share the same group by key.
      static <TExpression>
      BsonField
       fieldName, TExpression expression)
      Gets a field name for a $group operation representing the sample standard deviation of the values of the given expression when applied to all members of the group.
      static <TExpression>
      BsonField
       fieldName, TExpression expression)
      Gets a field name for a $group operation representing the sample standard deviation of the values of the given expression when applied to all members of the group.
      static <TExpression>
      BsonField
       fieldName, TExpression expression)
      Gets a field name for a $group operation representing the sum of the values of the given expression when applied to all members of the group.
      • Methods inherited from class java.lang.

        , , , , , , , , , ,
    • Method Detail

      • sum

        public static <TExpression>  fieldName,
                                                  TExpression expression)
        Gets a field name for a $group operation representing the sum of the values of the given expression when applied to all members of the group.
        Type Parameters:
        TExpression - the expression type
        Parameters:
        fieldName - the field name
        expression - the expression
        Returns:
        the field
        MongoDB documentation
      • avg

        public static <TExpression>  fieldName,
                                                  TExpression expression)
        Gets a field name for a $group operation representing the average of the values of the given expression when applied to all members of the group.
        Type Parameters:
        TExpression - the expression type
        Parameters:
        fieldName - the field name
        expression - the expression
        Returns:
        the field
        MongoDB documentation
      • first

        public static <TExpression>  fieldName,
                                                    TExpression expression)
        Gets a field name for a $group operation representing the value of the given expression when applied to the first member of the group.
        Type Parameters:
        TExpression - the expression type
        Parameters:
        fieldName - the field name
        expression - the expression
        Returns:
        the field
        MongoDB documentation
      • last

        public static <TExpression>  fieldName,
                                                   TExpression expression)
        Gets a field name for a $group operation representing the value of the given expression when applied to the last member of the group.
        Type Parameters:
        TExpression - the expression type
        Parameters:
        fieldName - the field name
        expression - the expression
        Returns:
        the field
        MongoDB documentation
      • max

        public static <TExpression>  fieldName,
                                                  TExpression expression)
        Gets a field name for a $group operation representing the maximum of the values of the given expression when applied to all members of the group.
        Type Parameters:
        TExpression - the expression type
        Parameters:
        fieldName - the field name
        expression - the expression
        Returns:
        the field
        MongoDB documentation
      • min

        public static <TExpression>  fieldName,
                                                  TExpression expression)
        Gets a field name for a $group operation representing the minimum of the values of the given expression when applied to all members of the group.
        Type Parameters:
        TExpression - the expression type
        Parameters:
        fieldName - the field name
        expression - the expression
        Returns:
        the field
        MongoDB documentation
      • push

        public static <TExpression>  fieldName,
                                                   TExpression expression)
        Gets a field name for a $group operation representing an array of all values that results from applying an expression to each document in a group of documents that share the same group by key.
        Type Parameters:
        TExpression - the expression type
        Parameters:
        fieldName - the field name
        expression - the expression
        Returns:
        the field
        MongoDB documentation
      • addToSet

        public static <TExpression>  fieldName,
                                                       TExpression expression)
        Gets a field name for a $group operation representing all unique values that results from applying the given expression to each document in a group of documents that share the same group by key.
        Type Parameters:
        TExpression - the expression type
        Parameters:
        fieldName - the field name
        expression - the expression
        Returns:
        the field
        MongoDB documentation
      • stdDevPop

        public static <TExpression>  fieldName,
                                                        TExpression expression)
        Gets a field name for a $group operation representing the sample standard deviation of the values of the given expression when applied to all members of the group.

        Use if the values encompass the entire population of data you want to represent and do not wish to generalize about a larger population.

        Type Parameters:
        TExpression - the expression type
        Parameters:
        fieldName - the field name
        expression - the expression
        Returns:
        the field
        Since:
        3.2
        MongoDB documentation
        Since server release
      • stdDevSamp

        public static <TExpression>  fieldName,
                                                         TExpression expression)
        Gets a field name for a $group operation representing the sample standard deviation of the values of the given expression when applied to all members of the group.

        Use if the values encompass a sample of a population of data from which to generalize about the population.

        Type Parameters:
        TExpression - the expression type
        Parameters:
        fieldName - the field name
        expression - the expression
        Returns:
        the field
        Since:
        3.2
        MongoDB documentation
        Since server release