t

reactivemongo.api.commands

AggregationFramework

trait AggregationFramework[P <: SerializationPack] extends GroupAggregation[P] with SliceAggregation[P] with SortAggregation[P] with AggregationPipeline[P] with ChangeStreamAggregation[P] with AtlasSearchAggregation[P]

Implements the Aggregation Framework.

Self Type
AggregationFramework[P] with PackSupport[P]
See also

PipelineOperator

Linear Supertypes
AtlasSearchAggregation[P], ChangeStreamAggregation[P], AggregationPipeline[P], SortAggregation[P], SliceAggregation[P], GroupAggregation[P], AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. AggregationFramework
  2. AtlasSearchAggregation
  3. ChangeStreamAggregation
  4. AggregationPipeline
  5. SortAggregation
  6. SliceAggregation
  7. GroupAggregation
  8. AnyRef
  9. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. final class AddFieldToSet extends GroupFunction

    The $addToSet group accumulator.

    The $addToSet group accumulator.

    Definition Classes
    GroupAggregation
  2. final class AddFields extends (AggregationFramework.this)#PipelineOperator

    $addFields stage.

    $addFields stage.

    Since

    MongoDB 3.4

  3. final class AddToSet extends GroupFunction

    The $addToSet group accumulator.

    The $addToSet group accumulator.

    Definition Classes
    GroupAggregation
  4. final class Ascending extends SortOrder

    Ascending sort order

    Ascending sort order

    Definition Classes
    SortAggregation
  5. final class AtlasSearch extends PipelineOperator

    EXPERIMENTAL: See AtlasSearch$

    EXPERIMENTAL: See AtlasSearch$

    Definition Classes
    AtlasSearchAggregation
  6. final class Avg extends GroupFunction

    The $avg group accumulator.

    The $avg group accumulator.

    Definition Classes
    GroupAggregation
  7. final class AvgField extends GroupFunction

    The $avg group accumulator.

    The $avg group accumulator.

    Definition Classes
    GroupAggregation
  8. final class Bucket extends (AggregationFramework.this)#PipelineOperator

    $bucket aggregation stage.

  9. final class BucketAuto extends (AggregationFramework.this)#PipelineOperator

    $bucket aggregation stage.

    $bucket aggregation stage.

    Since

    MongoDB 3.4 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. Document fields identifier must be prefixed with $.

  10. final class CollStats extends (AggregationFramework.this)#PipelineOperator

    $collStats aggregation stage.

  11. final class Count extends (AggregationFramework.this)#PipelineOperator

    $count of the number of documents input.

    $count of the number of documents input.

    Since

    MongoDB 3.4

  12. final class CurrentOp extends (AggregationFramework.this)#PipelineOperator

    $currentOp.

    Since

    MongoDB 3.6

  13. final class Cursor extends AnyRef

    Attributes
    protected
  14. final class Descending extends SortOrder

    Descending sort order

    Descending sort order

    Definition Classes
    SortAggregation
  15. final class Facet extends (AggregationFramework.this)#PipelineOperator

    Processes multiple aggregation pipelines within a single stage on the same set of input documents.

    Processes multiple aggregation pipelines within a single stage on the same set of input documents.

    Each sub-pipeline has its own field in the output document where its results are stored as an array of documents.

    See also

    https://docs.mongodb.com/manual/reference/operator/aggregation/facet/

  16. final class Filter extends AnyRef

    The $filter aggregation stage.

  17. final class First extends GroupFunction

    The $field group accumulator.

    The $field group accumulator.

    Definition Classes
    GroupAggregation
  18. final class FirstField extends GroupFunction

    The $field group accumulator.

    The $field group accumulator.

    Definition Classes
    GroupAggregation
  19. final class GeoNear extends (AggregationFramework.this)#PipelineOperator

    $geoNear aggregation stage, that outputs documents in order of nearest to farthest from a specified point.

  20. final class GraphLookup extends (AggregationFramework.this)#PipelineOperator

    The $graphLookup aggregation stage.

    The $graphLookup aggregation stage.

    Since

    MongoDB 3.4

  21. final class Group extends (AggregationFramework.this)#PipelineOperator

    $groups documents together to calculate aggregates on document collections.

    $groups documents together to calculate aggregates on document collections. This command aggregates on arbitrary identifiers. Document fields identifier must be prefixed with $.

  22. final class GroupField extends (AggregationFramework.this)#PipelineOperator

    $groups documents together to calculate aggregates on document collections.

    $groups documents together to calculate aggregates on document collections. This command aggregates on one field.

  23. sealed trait GroupFunction extends AnyRef

    Represents one of the group/accumulator operators, for the $group aggregation.

    Represents one of the group/accumulator operators, for the $group aggregation. Operation.

    Definition Classes
    GroupAggregation
    See also

    https://docs.mongodb.com/manual/reference/operator/aggregation/group/#accumulator-operator

  24. final class GroupMulti extends (AggregationFramework.this)#PipelineOperator

    $groups documents together to calculate aggregates on document collections.

    $groups documents together to calculate aggregates on document collections. This command aggregates on multiple fields, and they must be named.

  25. final class IndexStatAccesses extends AnyRef

  26. final class IndexStatsResult extends AnyRef

  27. final class Last extends GroupFunction

    The $field group accumulator.

    The $field group accumulator.

    Definition Classes
    GroupAggregation
  28. final class LastField extends GroupFunction

    The $field group accumulator.

    The $field group accumulator.

    Definition Classes
    GroupAggregation
  29. final class Limit extends (AggregationFramework.this)#PipelineOperator

    $limits the number of documents that pass through the stream.

  30. final class ListLocalSessions extends (AggregationFramework.this)#PipelineOperator

    $listLocalSessions aggregation stage.

    $listLocalSessions aggregation stage.

    Since

    MongoDB 3.6

  31. final class ListSessions extends (AggregationFramework.this)#PipelineOperator

    $listSessions aggregation stage.

    $listSessions aggregation stage.

    Since

    MongoDB 3.6

  32. final class Lookup extends (AggregationFramework.this)#PipelineOperator

    Performs a left outer join to an unsharded collection in the same database to filter in documents from the "joined" collection for processing.

    Performs a left outer join to an unsharded collection in the same database to filter in documents from the "joined" collection for processing.

    Since

    MongoDB 3.2

  33. final class Match extends (AggregationFramework.this)#PipelineOperator

    Filters out documents from the stream that do not match the predicate.

  34. final class Max extends GroupFunction

    The $max group accumulator.

    The $max group accumulator.

    Definition Classes
    GroupAggregation
  35. final class MaxField extends GroupFunction

    The $max group accumulator.

    The $max group accumulator.

    Definition Classes
    GroupAggregation
  36. final class Merge extends (AggregationFramework.this)#PipelineOperator

    $merge aggregation stage.

    $merge aggregation stage.

    Since

    MongoDB 4.2

  37. final class MergeObjects extends GroupFunction

    The $mergeObjects group accumulator.

    The $mergeObjects group accumulator.

    Definition Classes
    GroupAggregation
  38. sealed trait MetadataKeyword extends AnyRef

    Keyword of metadata.

    Definition Classes
    SortAggregation
  39. final class MetadataSort extends SortOrder

    Metadata sort order.

    Definition Classes
    SortAggregation
  40. final class Min extends GroupFunction

    The $min group accumulator.

    The $min group accumulator.

    Definition Classes
    GroupAggregation
  41. final class MinField extends GroupFunction

    The $min group accumulator.

    The $min group accumulator.

    Definition Classes
    GroupAggregation
  42. final class Out extends (AggregationFramework.this)#PipelineOperator

    Takes the documents returned by the aggregation pipeline and writes them to a specified collection

  43. type Pipeline = List[(AggregationFramework.this)#PipelineOperator]

    Aggregation pipeline (with at least one stage operator)

    Aggregation pipeline (with at least one stage operator)

    Definition Classes
    AggregationPipeline
  44. trait PipelineOperator extends AnyRef

    One of MongoDBs pipeline operators for aggregation.

    One of MongoDBs pipeline operators for aggregation. Sealed as these are defined in the MongoDB specifications, and clients should not have custom operators.

    Definition Classes
    AggregationPipeline
  45. final class Project extends (AggregationFramework.this)#PipelineOperator

    Reshapes a document stream by renaming, adding, or removing fields.

    Reshapes a document stream by renaming, adding, or removing fields. Also uses Project to create computed values or sub-objects.

  46. final class Push extends GroupFunction

    The $push group accumulator.

    The $push group accumulator.

    Definition Classes
    GroupAggregation
  47. final class PushField extends GroupFunction

    The $push group accumulator.

    The $push group accumulator.

    Definition Classes
    GroupAggregation
  48. final class Redact extends (AggregationFramework.this)#PipelineOperator

    Restricts the contents of the documents based on information stored in the documents themselves.

    Restricts the contents of the documents based on information stored in the documents themselves. http://docs.mongodb.org/manual/reference/operator/aggregation/redact/#pipe._S_redact Redact

  49. final class ReplaceRoot extends (AggregationFramework.this)#PipelineOperator

    Promotes a specified document to the top level and replaces all other fields.

    Promotes a specified document to the top level and replaces all other fields. The operation replaces all existing fields in the input document, including the _id field. https://docs.mongodb.com/manual/reference/operator/aggregation/replaceRoot

  50. final class ReplaceRootField extends (AggregationFramework.this)#PipelineOperator

    Promotes a specified document to the top level and replaces all other fields.

    Promotes a specified document to the top level and replaces all other fields. The operation replaces all existing fields in the input document, including the _id field. https://docs.mongodb.com/manual/reference/operator/aggregation/replaceRoot

  51. final class ReplaceWith extends (AggregationFramework.this)#PipelineOperator

    The $replaceWith aggregation stage.

    The $replaceWith aggregation stage.

    Since

    MongoDB 4.2

  52. final class Sample extends (AggregationFramework.this)#PipelineOperator

    $sample aggregation stage, that randomly selects the specified number of documents from its input.

  53. final class SearchString extends AnyRef

    EXPERIMENTAL: One or at least one string

    EXPERIMENTAL: One or at least one string

    Definition Classes
    AtlasSearchAggregation
  54. final class Set extends (AggregationFramework.this)#PipelineOperator

    $set aggregation stage

  55. final class Skip extends (AggregationFramework.this)#PipelineOperator

    $skips over a number of documents before passing all further documents along the stream.

  56. final class Slice extends PipelineOperator

    Returns a slice/subset of an array.

    Returns a slice/subset of an array.

    Definition Classes
    SliceAggregation
  57. final class Sort extends (AggregationFramework.this)#PipelineOperator

    $sorts the stream based on the given fields.

  58. final class SortByCount extends (AggregationFramework.this)#PipelineOperator

    The $sortByCount aggregation stage.

    The $sortByCount aggregation stage.

    Since

    MongoDB 3.4

  59. final class SortByFieldCount extends (AggregationFramework.this)#PipelineOperator

    The $sortByCount aggregation stage.

    The $sortByCount aggregation stage.

    Since

    MongoDB 3.4

  60. sealed trait SortOrder extends AnyRef

    Represents that a field should be sorted on, as well as whether it should be ascending or descending.

    Represents that a field should be sorted on, as well as whether it should be ascending or descending.

    Definition Classes
    SortAggregation
  61. final class StdDevPop extends GroupFunction

    The $stdDevPop group accumulator.

    The $stdDevPop group accumulator.

    Definition Classes
    GroupAggregation
    Since

    MongoDB 3.2

  62. final class StdDevPopField extends GroupFunction

    The $stdDevPop for a single field.

    The $stdDevPop for a single field.

    Definition Classes
    GroupAggregation
    Since

    MongoDB 3.2

  63. final class StdDevSamp extends GroupFunction

    The $stdDevSamp group accumulator

    The $stdDevSamp group accumulator

    Definition Classes
    GroupAggregation
    Since

    MongoDB 3.2

  64. final class StdDevSampField extends GroupFunction

    The $stdDevSamp for a single field

    The $stdDevSamp for a single field

    Definition Classes
    GroupAggregation
    Since

    MongoDB 3.2

  65. final class Sum extends GroupFunction

    The $sum group accumulator.

    The $sum group accumulator.

    Definition Classes
    GroupAggregation
  66. final class SumField extends GroupFunction

    The $sum group accumulator.

    The $sum group accumulator.

    Definition Classes
    GroupAggregation
  67. final class SumValue extends GroupFunction
    Definition Classes
    GroupAggregation
  68. final class Unset extends (AggregationFramework.this)#PipelineOperator

    The $unset aggregation stage.

    The $unset aggregation stage.

    Since

    MongoDB 4.2

  69. sealed trait Unwind extends (AggregationFramework.this)#PipelineOperator
  70. final class UnwindField extends (AggregationFramework.this)#Unwind

    Turns a document with an array into multiple documents, one document for each element in the array.

    Turns a document with an array into multiple documents, one document for each element in the array. http://docs.mongodb.org/manual/reference/aggregation/unwind/#_S_unwind

  71. final class ChangeStream extends AggregationFramework.PipelineOperator

    Low level pipeline operator which allows to open a tailable cursor against subsequent change events of a given collection.

    Low level pipeline operator which allows to open a tailable cursor against subsequent change events of a given collection.

    For common use-cases, you might prefer to use the watch operator on a collection.

    Note: the target mongo instance MUST be a replica-set (even in the case of a single node deployement).

    Definition Classes
    ChangeStreamAggregation
    Since

    MongoDB 3.6

Abstract Value Members

  1. abstract val pack: P
    Definition Classes
    AggregationPipeline

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from AggregationFramework[P] toany2stringadd[AggregationFramework[P]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (AggregationFramework[P], B)
    Implicit
    This member is added by an implicit conversion from AggregationFramework[P] toArrowAssoc[AggregationFramework[P]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. final lazy val builder: Builder[(AggregationFramework.this)#pack.type]
    Attributes
    protected
  8. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  9. def ensuring(cond: (AggregationFramework[P]) => Boolean, msg: => Any): AggregationFramework[P]
    Implicit
    This member is added by an implicit conversion from AggregationFramework[P] toEnsuring[AggregationFramework[P]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  10. def ensuring(cond: (AggregationFramework[P]) => Boolean): AggregationFramework[P]
    Implicit
    This member is added by an implicit conversion from AggregationFramework[P] toEnsuring[AggregationFramework[P]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  11. def ensuring(cond: Boolean, msg: => Any): AggregationFramework[P]
    Implicit
    This member is added by an implicit conversion from AggregationFramework[P] toEnsuring[AggregationFramework[P]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. def ensuring(cond: Boolean): AggregationFramework[P]
    Implicit
    This member is added by an implicit conversion from AggregationFramework[P] toEnsuring[AggregationFramework[P]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  13. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  15. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  16. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from AggregationFramework[P] toStringFormat[AggregationFramework[P]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  17. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  18. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  19. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  20. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  22. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  23. final def pipe(name: String, arg: P.Value): P.Document
    Attributes
    protected
    Annotations
    @inline()
  24. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  25. def toString(): String
    Definition Classes
    AnyRef → Any
  26. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  27. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  28. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  29. object AddFieldToSet
    Definition Classes
    GroupAggregation
  30. object AddFields
  31. object AddToSet
    Definition Classes
    GroupAggregation
  32. object Ascending
    Definition Classes
    SortAggregation
  33. object AtlasSearch

    EXPERIMENTAL: Atlas Search (only on MongoDB Atlas)

    EXPERIMENTAL: Atlas Search (only on MongoDB Atlas)

    Definition Classes
    AtlasSearchAggregation
  34. object Avg
    Definition Classes
    GroupAggregation
  35. object AvgField
    Definition Classes
    GroupAggregation
  36. object Bucket
  37. object BucketAuto
  38. object CollStats
  39. object Count
  40. object CurrentOp
  41. object Descending
    Definition Classes
    SortAggregation
  42. object Facet
  43. object Filter

    Filter companion

  44. object First
    Definition Classes
    GroupAggregation
  45. object FirstField
    Definition Classes
    GroupAggregation
  46. object GeoNear
  47. object GraphLookup
  48. object Group
  49. object GroupField
  50. object GroupFunction

    Factory to declare custom call to a group function.

    Factory to declare custom call to a group function.

    Definition Classes
    GroupAggregation
  51. object GroupMulti
  52. case object IndexStats extends (AggregationFramework.this)#PipelineOperator with Product with Serializable

    $indexStats aggregation stage.

    $indexStats aggregation stage.

    Since

    MongoDB 3.2

  53. object IndexStatsResult
  54. object Last
    Definition Classes
    GroupAggregation
  55. object LastField
    Definition Classes
    GroupAggregation
  56. object Limit
  57. object ListLocalSessions
  58. object ListSessions
  59. object Lookup
  60. object Match
  61. object Max
    Definition Classes
    GroupAggregation
  62. object MaxField
    Definition Classes
    GroupAggregation
  63. object Merge
  64. object MergeObjects
    Definition Classes
    GroupAggregation
  65. object MetadataSort
    Definition Classes
    SortAggregation
  66. object Min
    Definition Classes
    GroupAggregation
  67. object MinField
    Definition Classes
    GroupAggregation
  68. object Out
  69. object PipelineOperator

    Only for advanced user: Factory for stage not already provided in the API.

    Only for advanced user: Factory for stage not already provided in the API.

    For example for { $sample: { size: 2 } }

    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def foo(coll: BSONCollection) =
      coll.aggregateWith[BSONDocument]() { agg =>
        import agg.PipelineOperator
    
        List(PipelineOperator(BSONDocument(
          f"$$sample" -> BSONDocument("size" -> 2))))
      }
    Definition Classes
    AggregationPipeline
  70. case object PlanCacheStats extends (AggregationFramework.this)#PipelineOperator with Product with Serializable

    $planCacheStats aggregation stage.

    $planCacheStats aggregation stage.

    Since

    MongoDB 4.2

  71. object Project
  72. object Push
    Definition Classes
    GroupAggregation
  73. object PushField
    Definition Classes
    GroupAggregation
  74. object Redact
  75. object ReplaceRoot
  76. object ReplaceRootField
  77. object ReplaceWith
  78. object Sample
  79. object SearchString

    EXPERIMENTAL: Search string utilities

    EXPERIMENTAL: Search string utilities

    Definition Classes
    AtlasSearchAggregation
  80. object Set
  81. object Skip
  82. object Slice

    import reactivemongo.api.bson.{ BSONDocument, BSONInteger, BSONString }
    import reactivemongo.api.bson.collection.BSONCollection
    
    def foo(coll: BSONCollection) =
      coll.aggregateWith[BSONDocument]() { agg =>
        import agg.{ Project, Slice }
    
        // Define the pipeline stages
        List(Project(BSONDocument(
          "name" -> 1,
          "favorites" -> Slice(
            array = BSONString(f"$$favorites"),
            n = BSONInteger(3)))))
      }
    Definition Classes
    SliceAggregation
  83. object Sort
  84. object SortByCount
  85. object SortByFieldCount
  86. object StdDevPop
    Definition Classes
    GroupAggregation
  87. object StdDevPopField
    Definition Classes
    GroupAggregation
  88. object StdDevSamp
    Definition Classes
    GroupAggregation
  89. object StdDevSampField
    Definition Classes
    GroupAggregation
  90. object Sum
    Definition Classes
    GroupAggregation
  91. case object SumAll extends GroupFunction with Product with Serializable

    The $sum: 1 group accumulator.

    The $sum: 1 group accumulator.

    Definition Classes
    GroupAggregation
  92. object SumField
    Definition Classes
    GroupAggregation
  93. case object TextScore extends MetadataKeyword with Product with Serializable

    References the score associated with the corresponding $text query for each matching document.

    References the score associated with the corresponding $text query for each matching document.

    Definition Classes
    SortAggregation
  94. object Unset
  95. object Unwind
  96. object UnwindField
  97. object ChangeStream
    Definition Classes
    ChangeStreamAggregation

Deprecated Value Members

  1. def [B](y: B): (AggregationFramework[P], B)
    Implicit
    This member is added by an implicit conversion from AggregationFramework[P] toArrowAssoc[AggregationFramework[P]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use -> instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.

Inherited from AtlasSearchAggregation[P]

Inherited from ChangeStreamAggregation[P]

Inherited from AggregationPipeline[P]

Inherited from SortAggregation[P]

Inherited from SliceAggregation[P]

Inherited from GroupAggregation[P]

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd fromAggregationFramework[P] to any2stringadd[AggregationFramework[P]]

Inherited by implicit conversion StringFormat fromAggregationFramework[P] to StringFormat[AggregationFramework[P]]

Inherited by implicit conversion Ensuring fromAggregationFramework[P] to Ensuring[AggregationFramework[P]]

Inherited by implicit conversion ArrowAssoc fromAggregationFramework[P] to ArrowAssoc[AggregationFramework[P]]

Ungrouped