My Library Docs

Multi-root Sidebar

flex-layout

  • Getting Started

  • Guides

  • Reference

typed-rx-http

  • Getting Started

  • Guides

  • Reference

global-rx-state

  • Getting Started

  • Guides

  • Reference

webflux-fe-dev-assistant

reactive-mongo-dsl

Native Aggregation

Describes how to execute the Bson aggregation stage of the MongoDB Driver from the first stage without reimplementing new Driver features in DSL.


Driver-native root aggregation

aggregation() executes the Bson stages returned by the MongoDB Driver in the order they are called from the first stage. The DSL does not reimplement Driver aggregation operators but handles pipeline execution, mapping, Reactor publisher, and preview/explain connections. Document can also be passed directly as it is Bson.

java
Result mapping

execute()

Maps the result to the source entity type.

execute(ResultType.class)

Maps to a separate result type when the shape of the aggregation result differs from the source entity.

executeDocument()

Returns the raw MongoDB Document as is.

$score / $scoreFusion of MongoDB Driver 5.10

1.0.0 does not create a dedicated wrapper for $score and $scoreFusion. Since Driver 5.10's Aggregates.score(...) / Aggregates.scoreFusion(...) already returns a Bson stage, it is passed directly to stage(...).

java
java
Add Bson stage after Search / Vector
java

The stage(Bson) of Search/Vector comes immediately after the mandatory first stage $search/$vectorSearch. Features that require the stage itself to be the first in the pipeline use aggregation().

Aggregation publisher options
java

preview() and actual MongoDB explain() are also supported in the root aggregation builder.

© 2026 Byeolnaerim. All rights reserved.IntroductionPrivacy Policy