Class BucketOptions.OutputOperation

  • Enclosing class:
    BucketOptions

    public class BucketOptions.OutputOperation
    extends Object
    Defines an output for bucketauto stage, that consists of the fieldname and the accumulator
    • Constructor Detail

      • OutputOperation

        public OutputOperation​(String fieldName)
        Creates the output operation for given fieldname
        Parameters:
        fieldName - name of the output field
    • Method Detail

      • addToSet

        public BucketOptions addToSet​(String field)
        Returns an array of all unique values that results from applying an expression to each document in a group of documents that share the same group by key. Order of the elements in the output array is unspecified.
        Parameters:
        field - the field to process
        Returns:
        an Accumulator
        MongoDB documentation
        Aggregration Expression: $addToSet
      • average

        public BucketOptions average​(String field)
        Returns the average value of the numeric values that result from applying a specified expression to each document in a group of documents that share the same group by key. $avg ignores non-numeric values.
        Parameters:
        field - the field to process
        Returns:
        an Accumulator
        MongoDB documentation
        Aggregration Expression: $avg
      • sum

        public BucketOptions sum​(Object field)
        Calculates and returns the sum of all the numeric values that result from applying a specified expression to each document in a group of documents that share the same group by key. $sum ignores non-numeric values.
        Parameters:
        field - the field to process
        Returns:
        an Accumulator
        MongoDB documentation
        Aggregration Expression: $sum