diff --git a/config/redirects b/config/redirects index 4594ac51127..8b73cbcfb06 100644 --- a/config/redirects +++ b/config/redirects @@ -1797,6 +1797,7 @@ raw: /manual/core/wildcard -> ${base}/manual/core/index-wildcard/ [v3.6-v5.0]: /${version}/reference/operator/aggregation/tsIncrement/ -> ${base}/${version}/reference/operator/aggregation/ [v3.6-v5.0]: /${version}/reference/operator/aggregation/tsSecond/ -> ${base}/${version}/reference/operator/aggregation/ +[v3.6-v5.0]: /${version}/reference/operator/aggregation/densify/ -> ${base}/${version}/reference/operator/aggregation/ # # Redirects for new 5.0 pages diff --git a/source/images/densification-by-partition.png b/source/images/densification-by-partition.png new file mode 100644 index 00000000000..66c8819ab37 Binary files /dev/null and b/source/images/densification-by-partition.png differ diff --git a/source/images/densification-full-range.png b/source/images/densification-full-range.png new file mode 100644 index 00000000000..475c329fa78 Binary files /dev/null and b/source/images/densification-full-range.png differ diff --git a/source/includes/extracts-agg-stages.yaml b/source/includes/extracts-agg-stages.yaml index 4bcb0bc5f30..9ba03102545 100644 --- a/source/includes/extracts-agg-stages.yaml +++ b/source/includes/extracts-agg-stages.yaml @@ -42,6 +42,10 @@ content: | Distinct from the :group:`$count` aggregation accumulator. + * - :pipeline:`$densify` + + - .. include:: /includes/fact-densify-description.rst + * - :pipeline:`$documents` - Returns literal documents from input expressions. diff --git a/source/includes/fact-densify-description.rst b/source/includes/fact-densify-description.rst new file mode 100644 index 00000000000..324ff3f0609 --- /dev/null +++ b/source/includes/fact-densify-description.rst @@ -0,0 +1,2 @@ +Creates new documents in a sequence of documents where certain values +in a field are missing. diff --git a/source/includes/fact-densify-image-explanation.rst b/source/includes/fact-densify-image-explanation.rst new file mode 100644 index 00000000000..a5cfb5928c4 --- /dev/null +++ b/source/includes/fact-densify-image-explanation.rst @@ -0,0 +1,4 @@ +- The darker squares represent the original documents in the collection. + +- The lighter squares represent the documents created with + :pipeline:`$densify`. diff --git a/source/reference/operator/aggregation-pipeline.txt b/source/reference/operator/aggregation-pipeline.txt index 71b71c6e221..b4b5c5f241e 100644 --- a/source/reference/operator/aggregation-pipeline.txt +++ b/source/reference/operator/aggregation-pipeline.txt @@ -103,7 +103,12 @@ Alphabetical Listing of Stages * - :pipeline:`$currentOp` - Returns information on active and/or dormant operations for the - MongoDB deployment. To run, use the :method:`db.aggregate()` method. + MongoDB deployment. To run, use the :method:`db.aggregate()` + method. + + * - :pipeline:`$densify` + + - .. include:: /includes/fact-densify-description.rst * - :pipeline:`$facet` @@ -325,6 +330,7 @@ Alphabetical Listing of Stages /reference/operator/aggregation/collStats /reference/operator/aggregation/count /reference/operator/aggregation/currentOp + /reference/operator/aggregation/densify /reference/operator/aggregation/documents /reference/operator/aggregation/facet /reference/operator/aggregation/geoNear diff --git a/source/reference/operator/aggregation/densify.txt b/source/reference/operator/aggregation/densify.txt new file mode 100644 index 00000000000..a74f5c09093 --- /dev/null +++ b/source/reference/operator/aggregation/densify.txt @@ -0,0 +1,547 @@ +====================== +$densify (aggregation) +====================== + +.. default-domain:: mongodb + +.. contents:: On this page + :local: + :backlinks: none + :depth: 1 + :class: singlecol + +Definition +---------- + +.. pipeline:: $densify + + .. versionadded:: 5.1 + + .. include:: /includes/fact-densify-description.rst + + You can use :pipeline:`$densify` to: + + - Fill gaps in time series data. + - Add missing values between groups of data. + - Populate your data with a specified range of values. + +Syntax +------ + +The :pipeline:`$densify` stage has this syntax: + +.. code-block:: javascript + + { + $densify: { + field: , + partitionByFields: [ , ... ], + range: { + step: , + unit: