Interface AggregationPipeline

  • All Known Implementing Classes:
    AggregationPipelineImpl

    @Deprecated(since="2.0",
                forRemoval=true)
    public interface AggregationPipeline
    Deprecated, for removal: This API element is subject to removal in a future version.
    use Aggregation instead
    This defines the pipeline used in aggregation operations
    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      <U> Iterator<U> aggregate​(Class<U> target)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Executes the pipeline and aggregates the output in to the type mapped by the target type using the default options as defined in AggregationOptions.
      <U> Iterator<U> aggregate​(Class<U> target, com.mongodb.AggregationOptions options)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Executes the pipeline and aggregates the output in to the type mapped by the target type.
      <U> Iterator<U> aggregate​(Class<U> target, com.mongodb.AggregationOptions options, com.mongodb.ReadPreference readPreference)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Executes the pipeline and aggregates the output in to the type mapped by the target type.
      <U> Iterator<U> aggregate​(String collectionName, Class<U> target, com.mongodb.AggregationOptions options, com.mongodb.ReadPreference readPreference)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Executes the pipeline and aggregates the output in to the type mapped by the target type.
      AggregationPipeline bucket​(String field, List<?> boundaries)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Categorizes incoming documents into groups, called buckets, based on a specified expression and bucket boundaries.
      AggregationPipeline bucket​(String field, List<?> boundaries, BucketOptions options)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Categorizes incoming documents into groups, called buckets, based on a specified expression and bucket boundaries.
      AggregationPipeline bucketAuto​(String field, int bucketCount)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Categorizes incoming documents into a specific number of groups, called buckets, based on a specified expression.
      AggregationPipeline bucketAuto​(String field, int bucketCount, BucketAutoOptions options)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Categorizes incoming documents into a specific number of groups, called buckets, based on a specified expression.
      AggregationPipeline geoNear​(GeoNear geoNear)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns an ordered stream of documents based on the proximity to a geospatial point.
      AggregationPipeline group​(Group... groupings)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Groups input documents by a specified identifier expression and applies the accumulator expression(s), if specified, to each group .
      AggregationPipeline group​(String id, Group... groupings)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Groups input documents by a specified identifier expression and applies the accumulator expression(s), if specified, to each group.
      AggregationPipeline group​(List<Group> id, Group... groupings)
      Deprecated, for removal: This API element is subject to removal in a future version.
       
      AggregationPipeline limit​(int count)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Passes the first n documents unmodified to the pipeline where n is the specified limit.
      AggregationPipeline lookup​(String from, String localField, String foreignField, String as)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Performs a left outer join to an unsharded collection in the same database to filter in documents from the "joined" collection for processing.
      AggregationPipeline match​(Query query)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Filters the document stream to allow only matching documents to pass unmodified into the next pipeline stage.
      <U> Iterator<U> out​(Class<U> target)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Places the output of the aggregation in the collection mapped by the target type using the default options as defined in AggregationOptions.
      <U> Iterator<U> out​(Class<U> target, com.mongodb.AggregationOptions options)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Places the output of the aggregation in the collection mapped by the target type.
      <U> Iterator<U> out​(String collectionName, Class<U> target)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Places the output of the aggregation in the collection mapped by the target type using the default options as defined in AggregationOptions.
      <U> Iterator<U> out​(String collectionName, Class<U> target, com.mongodb.AggregationOptions options)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Places the output of the aggregation in the collection mapped by the target type.
      AggregationPipeline project​(Projection... projections)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Reshapes each document in the stream, such as by adding new fields or removing existing fields.
      AggregationPipeline sample​(int sampleSize)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Randomly selects the specified number of documents from the previous pipeline stage.
      AggregationPipeline skip​(int count)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Skips the first n documents where n is the specified skip number and passes the remaining documents unmodified to the pipeline.
      AggregationPipeline sort​(Sort... sorts)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Reorders the document stream by a specified sort key.
      AggregationPipeline sortByCount​(String field)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Groups incoming documents based on the value of a specified expression, then computes the count of documents in each distinct group.
      AggregationPipeline unwind​(String field)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Deconstructs an array field from the input documents to output a document for each element.
      AggregationPipeline unwind​(String field, com.mongodb.client.model.UnwindOptions options)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Deconstructs an array field from the input documents to output a document for each element.
    • Method Detail

      • aggregate

        <U> Iterator<U> aggregate​(Class<U> target)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Executes the pipeline and aggregates the output in to the type mapped by the target type using the default options as defined in AggregationOptions. Note: This return type will change to MongoCursor in 2.0 to allow for finer-grained control of iteration and resource management.
        Type Parameters:
        U - type of the results
        Parameters:
        target - The class to use when iterating over the results
        Returns:
        an iterator of the computed results
      • aggregate

        <U> Iterator<U> aggregate​(Class<U> target,
                                  com.mongodb.AggregationOptions options)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Executes the pipeline and aggregates the output in to the type mapped by the target type. Note: This return type will change to MongoCursor in 2.0 to allow for finer-grained control of iteration and resource management.
        Type Parameters:
        U - type of the results
        Parameters:
        target - The class to use when iterating over the results
        options - The options to apply to this aggregation
        Returns:
        an iterator of the computed results
      • aggregate

        <U> Iterator<U> aggregate​(Class<U> target,
                                  com.mongodb.AggregationOptions options,
                                  com.mongodb.ReadPreference readPreference)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Executes the pipeline and aggregates the output in to the type mapped by the target type. Note: This return type will change to MongoCursor in 2.0 to allow for finer-grained control of iteration and resource management.
        Type Parameters:
        U - type of the results
        Parameters:
        target - The class to use when iterating over the results
        options - The options to apply to this aggregation
        readPreference - The read preference to apply to this pipeline
        Returns:
        an iterator of the computed results
      • aggregate

        <U> Iterator<U> aggregate​(String collectionName,
                                  Class<U> target,
                                  com.mongodb.AggregationOptions options,
                                  com.mongodb.ReadPreference readPreference)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Executes the pipeline and aggregates the output in to the type mapped by the target type. Note: This return type will change to MongoCursor in 2.0 to allow for finer-grained control of iteration and resource management.
        Type Parameters:
        U - type of the results
        Parameters:
        collectionName - The collection in which to store the results of the aggregation overriding the mapped value in target
        target - The class to use when iterating over the results
        options - The options to apply to this aggregation
        readPreference - The read preference to apply to this pipeline
        Returns:
        an iterator of the computed results
      • bucket

        AggregationPipeline bucket​(String field,
                                   List<?> boundaries)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Categorizes incoming documents into groups, called buckets, based on a specified expression and bucket boundaries.

        Each bucket is represented as a document in the output. The document for each bucket contains an _id field, whose value specifies the inclusive lower bound of the bucket and a count field that contains the number of documents in the bucket. The count field is included by default when the output is not specified.

        Parameters:
        field - the field that used as groupby for bucketing
        boundaries - An array of values based on the groupBy expression that specify the boundaries for each bucket. Each adjacent pair of values acts as the inclusive lower boundary and the exclusive upper boundary for the bucket. You must specify at least two boundaries.
        Returns:
        this
        Since:
        1.5
        MongoDB documentation
        $bucket
      • bucket

        AggregationPipeline bucket​(String field,
                                   List<?> boundaries,
                                   BucketOptions options)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Categorizes incoming documents into groups, called buckets, based on a specified expression and bucket boundaries.

        Each bucket is represented as a document in the output. The document for each bucket contains an _id field, whose value specifies the inclusive lower bound of the bucket and a count field that contains the number of documents in the bucket. The count field is included by default when the output is not specified.

        Parameters:
        field - the field that used as groupby for bucketing
        boundaries - An array of values based on the groupBy expression that specify the boundaries for each bucket. Each adjacent pair of values acts as the inclusive lower boundary and the exclusive upper boundary for the bucket. You must specify at least two boundaries.
        options - options that include defaultField for values that not match in any boundaries and also allow to specify output by using accumulator Accumulator
        Returns:
        this
        Since:
        1.5
        MongoDB documentation
        $bucket
      • bucketAuto

        AggregationPipeline bucketAuto​(String field,
                                       int bucketCount)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Categorizes incoming documents into a specific number of groups, called buckets, based on a specified expression. Bucket boundaries are automatically determined in an attempt to evenly distribute the documents into the specified number of buckets.

        Each bucket is represented as a document in the output. The document for each bucket contains an _id field, whose value specifies the inclusive lower bound and the exclusive upper bound for the bucket, and a count field that contains the number of documents in the bucket. The count field is included by default when the output is not specified.

        Parameters:
        field - the field that used as groupby for auto bucketing
        bucketCount - the number of buckets into which input documents are grouped
        Returns:
        this
        Since:
        1.5
        MongoDB documentation
        $bucketAuto
      • bucketAuto

        AggregationPipeline bucketAuto​(String field,
                                       int bucketCount,
                                       BucketAutoOptions options)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Categorizes incoming documents into a specific number of groups, called buckets, based on a specified expression. Bucket boundaries are automatically determined in an attempt to evenly distribute the documents into the specified number of buckets.

        Each bucket is represented as a document in the output. The document for each bucket contains an _id field, whose value specifies the inclusive lower bound and the exclusive upper bound for the bucket, and a count field that contains the number of documents in the bucket. The count field is included by default when the output is not specified.

        Parameters:
        field - the field that used as groupby for auto bucketing
        bucketCount - the number of buckets into which input documents are grouped
        options - options that include granularity for buckets and output
        Returns:
        this
        Since:
        1.5
        MongoDB documentation
        $bucketAuto
      • geoNear

        AggregationPipeline geoNear​(GeoNear geoNear)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Returns an ordered stream of documents based on the proximity to a geospatial point. Incorporates the functionality of $match, $sort, and $limit for geospatial data. The output documents include an additional distance field and can include a location identifier field.
        Parameters:
        geoNear - the geospatial parameters to apply to the pipeline
        Returns:
        this
        MongoDB documentation
        Aggregration Expression: $geoNear
      • group

        AggregationPipeline group​(Group... groupings)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Groups input documents by a specified identifier expression and applies the accumulator expression(s), if specified, to each group . Consumes all input documents and outputs one document per each distinct group. The output documents only contain the identifier field and, if specified, accumulated fields. The ID for this group is null.
        Parameters:
        groupings - the group definitions
        Returns:
        this
        MongoDB documentation
        Aggregration Expression: $group
      • group

        AggregationPipeline group​(String id,
                                  Group... groupings)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Groups input documents by a specified identifier expression and applies the accumulator expression(s), if specified, to each group. Consumes all input documents and outputs one document per each distinct group. The output documents only contain the identifier field and, if specified, accumulated fields.
        Parameters:
        id - the ID of the group create
        groupings - the group definitions
        Returns:
        this
        MongoDB documentation
        Aggregration Expression: $group
      • limit

        AggregationPipeline limit​(int count)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Passes the first n documents unmodified to the pipeline where n is the specified limit. For each input document, outputs either one document (for the first n documents) or zero documents (after the first n documents).
        Parameters:
        count - the maximum number of documents to return
        Returns:
        this
        MongoDB documentation
        Aggregration Expression: $limit
      • lookup

        AggregationPipeline lookup​(String from,
                                   String localField,
                                   String foreignField,
                                   String as)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Performs a left outer join to an unsharded collection in the same database to filter in documents from the "joined" collection for processing. The $lookup stage does an equality match between a field from the input documents with a field from the documents of the “joined” collection. To each input document, the $lookup stage adds a new array field whose elements are the matching documents from the “joined” collection. The $lookup stage passes these reshaped documents to the next stage.
        Parameters:
        from - the collection to join
        localField - the field from the input documents
        foreignField - the field from the documents of the "from" collection
        as - the output array field
        Returns:
        this
        Since:
        1.2
        MongoDB documentation
        Aggregration Expression: $lookup
      • match

        AggregationPipeline match​(Query query)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Filters the document stream to allow only matching documents to pass unmodified into the next pipeline stage. $match uses standard MongoDB queries. For each input document, outputs either one document (a match) or zero documents (no match).
        Parameters:
        query - the query to use when matching
        Returns:
        this
        MongoDB documentation
        Aggregration Expression: $match
      • out

        <U> Iterator<U> out​(Class<U> target)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Places the output of the aggregation in the collection mapped by the target type using the default options as defined in AggregationOptions.
        Type Parameters:
        U - type of the results
        Parameters:
        target - The class to use when iterating over the results
        Returns:
        an iterator of the computed results
        MongoDB documentation
        Aggregration Expression: $out
      • out

        <U> Iterator<U> out​(Class<U> target,
                            com.mongodb.AggregationOptions options)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Places the output of the aggregation in the collection mapped by the target type.
        Type Parameters:
        U - type of the results
        Parameters:
        target - The class to use when iterating over the results
        options - The options to apply to this aggregation
        Returns:
        an iterator of the computed results
        MongoDB documentation
        Aggregration Expression: $out
      • out

        <U> Iterator<U> out​(String collectionName,
                            Class<U> target)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Places the output of the aggregation in the collection mapped by the target type using the default options as defined in AggregationOptions.
        Type Parameters:
        U - type of the results
        Parameters:
        collectionName - The collection in which to store the results of the aggregation overriding the mapped value in target
        target - The class to use when iterating over the results
        Returns:
        an iterator of the computed results
        MongoDB documentation
        Aggregration Expression: $out
      • out

        <U> Iterator<U> out​(String collectionName,
                            Class<U> target,
                            com.mongodb.AggregationOptions options)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Places the output of the aggregation in the collection mapped by the target type.
        Type Parameters:
        U - type of the results
        Parameters:
        collectionName - The collection in which to store the results of the aggregation overriding the mapped value in target
        target - The class to use when iterating over the results
        options - The options to apply to this aggregation
        Returns:
        an iterator of the computed results
        MongoDB documentation
        Aggregration Expression: $out
      • project

        AggregationPipeline project​(Projection... projections)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Reshapes each document in the stream, such as by adding new fields or removing existing fields. For each input document, outputs one document.
        Parameters:
        projections - the projections to apply to this pipeline
        Returns:
        this
        MongoDB documentation
        Aggregration Expression: $project
      • sample

        AggregationPipeline sample​(int sampleSize)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Randomly selects the specified number of documents from the previous pipeline stage.
        Parameters:
        sampleSize - the number of documents to select
        Returns:
        this
        MongoDB documentation
        Aggregration Expression: $sample
      • skip

        AggregationPipeline skip​(int count)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Skips the first n documents where n is the specified skip number and passes the remaining documents unmodified to the pipeline. For each input document, outputs either zero documents (for the first n documents) or one document (if after the first n documents).
        Parameters:
        count - the number of documents to skip
        Returns:
        this
        MongoDB documentation
        Aggregration Expression: $skip
      • sort

        AggregationPipeline sort​(Sort... sorts)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Reorders the document stream by a specified sort key. Only the order changes; the documents remain unmodified. For each input document, outputs one document.
        Parameters:
        sorts - the sorts to apply to this pipeline
        Returns:
        this
        MongoDB documentation
        Aggregration Expression: $sort
      • sortByCount

        AggregationPipeline sortByCount​(String field)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Groups incoming documents based on the value of a specified expression, then computes the count of documents in each distinct group.

        Each output document contains two fields: an _id field containing the distinct grouping value, and a count field containing the number of documents belonging to that grouping or category.

        Parameters:
        field - the field to sort by count
        Returns:
        this
        Since:
        1.5
        MongoDB documentation
        Aggregration Expression: $sortByCount
      • unwind

        AggregationPipeline unwind​(String field,
                                   com.mongodb.client.model.UnwindOptions options)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Deconstructs an array field from the input documents to output a document for each element. Each output document replaces the array with an element value. For each input document, outputs n documents where n is the number of array elements and can be zero for an empty array.
        Parameters:
        field - the field to unwind
        options - unwind options
        Returns:
        this
      • unwind

        AggregationPipeline unwind​(String field)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Deconstructs an array field from the input documents to output a document for each element. Each output document replaces the array with an element value. For each input document, outputs n documents where n is the number of array elements and can be zero for an empty array.
        Parameters:
        field - the field to unwind
        Returns:
        this
        MongoDB documentation
        Aggregration Expression: $unwind