Builds a computation that adds the evaluation results of the expression
over the window
to a BSON Array
and excludes duplicates.
Builds a computation that adds the evaluation results of the expression
over the window
to a BSON Array
and excludes duplicates.
Order within the array is not specified.
The expression type.
The output field path.
The expression.
The window. May be null
.
The constructed windowed computation.
Builds a computation of the average of the evaluation results of the expression
over the window
.
Builds a computation of the average of the evaluation results of the expression
over the window
.
The expression type.
The output field path.
The expression.
The window. May be null
.
The constructed windowed computation.
Builds a computation of the number of documents in the window
.
Builds a computation of the number of documents in the window
.
The output field path.
The window. May be null
.
The constructed windowed computation.
Builds a computation of the population covariance between the evaluation results of the two expressions over the window
.
Builds a computation of the population covariance between the evaluation results of the two expressions over the window
.
The expression type.
The output field path.
The first expression.
The second expression.
The window. May be null
.
The constructed windowed computation.
Builds a computation of the sample covariance between the evaluation results of the two expressions over the window
.
Builds a computation of the sample covariance between the evaluation results of the two expressions over the window
.
The expression type.
The output field path.
The first expression.
The second expression.
The window. May be null
.
The constructed windowed computation.
Builds a computation of the dense rank of each document in its partition.
Builds a computation of the dense rank of each document in its
partition.
Documents with the same value(s) of the sortBy fields result in
the same ranking but do not result in gaps in the returned ranks.
For example, a partition with the sequence [1, 3, 3, 5] representing the values of the single sortBy
field
produces the following sequence of rank values: [1, 2, 2, 3].
Sorting is required.
The output field path.
The constructed windowed computation.
Builds a computation of the time derivative by subtracting the evaluation result of the expression
against the last document
and the first document in the window
and dividing it by the difference in the values of the
sortBy field of the respective documents.
Builds a computation of the time derivative by subtracting the evaluation result of the expression
against the last document
and the first document in the window
and dividing it by the difference in the values of the
sortBy field of the respective documents.
Other documents in the window
have no effect on the computation.
Sorting is required.
The expression type.
The output field path.
The expression.
The window.
The constructed windowed computation.
Builds a computation of the order number of each document in its partition.
The output field path.
The constructed windowed computation.
Builds a computation of the exponential moving average of the evaluation results of the expression
over the half-bounded
window [
UNBOUNDED, CURRENT]
,
with alpha
representing the degree of weighting decrease.
Builds a computation of the exponential moving average of the evaluation results of the expression
over the half-bounded
window [
UNBOUNDED, CURRENT]
,
with alpha
representing the degree of weighting decrease.
Sorting is required.
The expression type.
The output field path.
The expression.
A parameter specifying how fast weighting decrease happens. A higher alpha
discounts older observations faster.
Must belong to the interval (0, 1).
The constructed windowed computation.
Builds a computation of the exponential moving average of the evaluation results of the expression
over a window
that includes n
- 1 documents preceding the current document and the current document, with more weight on documents
closer to the current one.
Builds a computation of the exponential moving average of the evaluation results of the expression
over a window
that includes n
- 1 documents preceding the current document and the current document, with more weight on documents
closer to the current one.
Sorting is required.
The expression type.
The output field path.
The expression.
Must be positive.
The constructed windowed computation.
Builds a computation of the evaluation result of the expression
against the first document in the window
.
Builds a computation of the approximate integral of a function that maps values of
the sortBy field to evaluation results of the expression
against the same document.
Builds a computation of the approximate integral of a function that maps values of
the sortBy field to evaluation results of the expression
against the same document. The limits of integration match the window
bounds.
The approximation is done by using the
trapezoidal rule.
Sorting is required.
The expression type.
The output field path.
The expression.
The window.
The constructed windowed computation.
Builds a computation of the evaluation result of the expression
against the last document in the window
.
Builds a computation of the highest of the evaluation results of the expression
over the window
.
Builds a computation of the highest of the evaluation results of the expression
over the window
.
The expression type.
The output field path.
The expression.
The window. May be null
.
The constructed windowed computation.
Builds a computation of the lowest of the evaluation results of the expression
over the window
.
Builds a computation of the lowest of the evaluation results of the expression
over the window
.
The expression type.
The output field path.
The expression.
The window. May be null
.
The constructed windowed computation.
Creates a windowed computation from a document field in situations when there is no builder method that better satisfies your needs.
Creates a windowed computation from a document field in situations when there is no builder method that better satisfies your needs. This method cannot be used to validate the document field syntax.
val pastWeek: Window = Windows.timeRange(-1, MongoTimeUnit.WEEK, Windows.Bound.CURRENT) val pastWeekExpenses1: WindowedComputation = WindowedComputations.sum("pastWeekExpenses", "$expenses", pastWeek) val pastWeekExpenses2: WindowedComputation = WindowedComputations.of( BsonField("pastWeekExpenses", Document("$sum" -> "$expenses", "window" -> pastWeek.toBsonDocument)))
A document field representing the required windowed computation.
The constructed windowed computation.
Builds a computation that adds the evaluation results of the expression
over the window
to a BSON Array
.
Builds a computation that adds the evaluation results of the expression
over the window
to a BSON Array
.
Order within the array is guaranteed if sortBy is specified.
The expression type.
The output field path.
The expression.
The window. May be null
.
The constructed windowed computation.
Builds a computation of the rank of each document in its partition.
Builds a computation of the rank of each document in its
partition.
Documents with the same value(s) of the sortBy fields result in
the same ranking and result in gaps in the returned ranks.
For example, a partition with the sequence [1, 3, 3, 5] representing the values of the single sortBy
field
produces the following sequence of rank values: [1, 2, 2, 4].
Sorting is required.
The output field path.
The constructed windowed computation.
Builds a computation of the evaluation result of the expression
for the document whose position is shifted by the given
amount relative to the current document.
Builds a computation of the evaluation result of the expression
for the document whose position is shifted by the given
amount relative to the current document. If the shifted document is outside of the
partition containing the current document,
then the defaultExpression
is used instead of the expression
.
Sorting is required.
The expression type.
The output field path.
The expression.
The default expression.
If null
, then the default expression is evaluated to BSON Null
.
Must evaluate to a constant value.
The shift specified similarly to rules for window bounds:
The constructed windowed computation.
Builds a computation of the population standard deviation of the evaluation results of the expression
over the window
.
Builds a computation of the population standard deviation of the evaluation results of the expression
over the window
.
The expression type.
The output field path.
The expression.
The window. May be null
.
The constructed windowed computation.
Builds a computation of the sample standard deviation of the evaluation results of the expression
over the window
.
Builds a computation of the sample standard deviation of the evaluation results of the expression
over the window
.
The expression type.
The output field path.
The expression.
The window. May be null
.
The constructed windowed computation.
Builds a computation of the sum of the evaluation results of the expression
over the window
.
Builds a computation of the sum of the evaluation results of the expression
over the window
.
The expression type.
The output field path.
The expression.
The window. May be null
.
The constructed windowed computation.
Builds a computation of the time derivative by subtracting the evaluation result of the expression
against the last document
and the first document in the window
and dividing it by the difference in the BSON Date
values of the sortBy field of the respective documents.
Builds a computation of the time derivative by subtracting the evaluation result of the expression
against the last document
and the first document in the window
and dividing it by the difference in the BSON Date
values of the sortBy field of the respective documents.
Other documents in the window
have no effect on the computation.
Sorting is required.
The expression type.
The output field path.
The expression.
The window.
The desired time unit for the divisor. Allowed values are: WEEK, DAY, HOUR, MINUTE, SECOND, MILLISECOND.
The constructed windowed computation.
Builds a computation of the approximate integral of a function that maps BSON Date
values of
the sortBy field to evaluation results of the expression
against the same document.
Builds a computation of the approximate integral of a function that maps BSON Date
values of
the sortBy field to evaluation results of the expression
against the same document. The limits of integration match the window
bounds.
The approximation is done by using the trapezoidal rule.
Sorting is required.
The expression type.
The output field path.
The expression.
The window.
The desired time unit for the divisor. Allowed values are: WEEK, DAY, HOUR, MINUTE, SECOND, MILLISECOND.
The constructed windowed computation.
(Since version ) see corresponding Javadoc for more information.
Builders for windowed computations used in the $setWindowFields pipeline stage of an aggregation pipeline. Each windowed computation is a triple:
sortBy
in Aggregates.setWindowFields).null
window is equivalent to specifying an unbounded window, i.e., a window with both ends specified as UNBOUNDED. Some window functions require to specify an explicit unbounded window instead of specifyingnull
.A windowed computation is similar to an accumulator but does not result in folding documents constituting the window into a single document.
4.3
Requires MongoDB 5.0 or greater.
Field paths