<section>
 <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium">
  $densify (aggregation)
  <a class="headerlink leafygreen-ui-1kepx47" href="#-densify--aggregation-" title="Permalink to this heading">
   <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
    <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
    </path>
    <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
    </path>
   </svg>
   <div class="css-1btu0w3 evvkmar0" id="-densify--aggregation-">
   </div>
  </a>
 </h1>
 <div class="leafygreen-ui-a5yxub">
  <p class="css-1cmx2d4 ef7gu8j0">
   On this page
  </p>
  <ul class="css-1qb0mst ef7gu8j1">
   <li class="leafygreen-ui-1e7a0ei">
    <a class="lg-ui-0001 leafygreen-ui-e98ikf" href="#definition" target="_self">
     <span>
      Definition
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#syntax" target="_self">
     <span>
      Syntax
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#behavior-and-restrictions" target="_self">
     <span>
      Behavior and Restrictions
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#examples" target="_self">
     <span>
      Examples
     </span>
    </a>
   </li>
  </ul>
 </div>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Definition
   <a class="headerlink leafygreen-ui-1kepx47" href="#definition" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="definition">
    </div>
   </a>
  </h2>
  <dl class="pipeline">
   <dt>
    <code class="leafygreen-ui-1l06pbn">
     $densify
    </code>
    <a class="headerlink leafygreen-ui-1kepx47" href="#mongodb-pipeline-pipe.-densify" title="Permalink to this definition">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="mongodb-pipeline-pipe.-densify">
     </div>
    </a>
   </dt>
   <dd>
    <div>
     <p>
      <em>
       New
       <!-- -->
       in version
       <!-- -->
       5.1
      </em>
      .
     </p>
    </div>
    <p class="leafygreen-ui-1kp3ins">
     Creates new documents in a sequence of documents where certain values
in a field are missing.
    </p>
    <p class="leafygreen-ui-1kp3ins">
     You can use
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
      <span>
       <code class="leafygreen-ui-1l06pbn">
        $densify
       </code>
      </span>
     </a>
     to:
    </p>
    <ul class="leafygreen-ui-rioki0">
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       Fill gaps in time series data.
      </p>
     </li>
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       Add missing values between groups of data.
      </p>
     </li>
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       Populate your data with a specified range of values.
      </p>
     </li>
    </ul>
   </dd>
  </dl>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Syntax
   <a class="headerlink leafygreen-ui-1kepx47" href="#syntax" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="syntax">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   The
   <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
    <span>
     <code class="leafygreen-ui-1l06pbn">
      $densify
     </code>
    </span>
   </a>
   stage has this syntax:
  </p>
  <script class="structured_data" type="application/ld+json">
   {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{\n   $densify: {\n      field: &lt;fieldname&gt;,\n      partitionByFields: [ &lt;field&gt;, &lt;field&gt; ... &lt;field&gt; ],\n      range: {\n         step: &lt;number&gt;,\n         unit: <time>,\n         bounds: &lt; \"full\" || \"partition\" &gt; || [ &lt; lower bound &gt;, &lt; upper bound &gt; ]\n      }\n   }\n}</time>"}
  </script>
  <div class="css-16lmvu9">
   <div class="leafygreen-ui-196mwvg">
    <div class="leafygreen-ui-1b1bvay">
     <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light none leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   $densify: {</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      field: &lt;fieldName&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      partitionByFields: [ &lt;field 1&gt;, &lt;field 2&gt; ... &lt;field n&gt; ],</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      range: {</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         step: &lt;number&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         unit: &lt;time unit&gt;,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         bounds: &lt; "full" || "partition" &gt; || [ &lt; lower bound &gt;, &lt; upper bound &gt; ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">}</td></tr></tbody></table></code></pre>
     <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
      <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
       <div class="leafygreen-ui-xhlipt">
        <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
         <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
         </path>
        </svg>
       </div>
      </button>
     </div>
    </div>
   </div>
  </div>
  <p class="leafygreen-ui-1kp3ins">
   The
   <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
    <span>
     <code class="leafygreen-ui-1l06pbn">
      $densify
     </code>
    </span>
   </a>
   stage takes a document with these fields:
  </p>
  <div class="leafygreen-ui-skkc39" tabindex="0">
   <table class="leafygreen-ui-hr8lsv">
    <colgroup>
     <col style="width:25%"/>
     <col style="width:15%"/>
     <col style="width:70%"/>
    </colgroup>
    <thead class="leafygreen-ui-a9ho40">
     <tr data-testid="leafygreen-ui-header-row">
      <th class="leafygreen-ui-1trtg6r" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Field
        </div>
       </div>
      </th>
      <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Necessity
        </div>
       </div>
      </th>
      <th class="leafygreen-ui-13uteka" role="columnheader" scope="col">
       <div class="leafygreen-ui-ui0te9">
        <div>
         Description
        </div>
       </div>
      </th>
     </tr>
    </thead>
    <tbody>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-field" target="_self">
          <span>
           field
          </span>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Required
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <span class="leafygreen-ui-1qnjd6d" id="std-label-densify-field">
         </span>
         <p class="leafygreen-ui-1kp3ins">
          The field to densify. The values of the specified
          <code class="leafygreen-ui-1l06pbn">
           field
          </code>
          must either be all numeric values or all dates.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          Documents that do not contain the specified
          <code class="leafygreen-ui-1l06pbn">
           field
          </code>
          continue
through the pipeline unmodified.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          To specify a
          <code class="leafygreen-ui-1l06pbn">
           &lt;field&gt;
          </code>
          in an embedded document or in an array, use
          <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/document/#std-label-document-dot-notation">
           dot notation
           <!-- -->
           .
          </a>
         </p>
         <p class="leafygreen-ui-1kp3ins">
          For restrictions, see
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-field-restrictions" target="_self">
           <span>
            <code class="leafygreen-ui-1l06pbn">
             field
            </code>
            Restrictions
            <!-- -->
            .
           </span>
          </a>
         </p>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-partition-by-fields" target="_self">
          <span>
           partitionByFields
          </span>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Optional
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <span class="leafygreen-ui-1qnjd6d" id="std-label-densify-partition-by-fields">
         </span>
         <p class="leafygreen-ui-1kp3ins">
          The set of fields to act as the compound key to group
the documents. In the
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
           <span>
            <code class="leafygreen-ui-1l06pbn">
             $densify
            </code>
           </span>
          </a>
          stage, each group of
documents is known as a
          <em>
           partition
          </em>
          .
         </p>
         <p class="leafygreen-ui-1kp3ins">
          If you omit this field,
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
           <span>
            <code class="leafygreen-ui-1l06pbn">
             $densify
            </code>
           </span>
          </a>
          uses one partition
for the entire collection.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          For an example, see
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-examples-partitions" target="_self">
           <span>
            Densifiction with Partitions
            <!-- -->
            .
           </span>
          </a>
         </p>
         <p class="leafygreen-ui-1kp3ins">
          For restrictions, see
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-partition-by-fields-restrictions" target="_self">
           <span>
            <code class="leafygreen-ui-1l06pbn">
             partitionByFields
            </code>
            Restrictions
            <!-- -->
            .
           </span>
          </a>
         </p>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-range" target="_self">
          <span>
           range
          </span>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Required
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <span class="leafygreen-ui-1qnjd6d" id="std-label-densify-range">
         </span>
         <p class="leafygreen-ui-1kp3ins">
          An object that specifies how the data is densified.
         </p>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-bounds" target="_self">
          <span>
           range.bounds
          </span>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Required
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <span class="leafygreen-ui-1qnjd6d" id="std-label-densify-bounds">
         </span>
         <p class="leafygreen-ui-1kp3ins">
          You can specify
          <code class="leafygreen-ui-1l06pbn">
           range.bounds
          </code>
          as either:
         </p>
         <ul class="leafygreen-ui-rioki0">
          <li class="leafygreen-ui-d7p7b6">
           <p class="leafygreen-ui-1kp3ins">
            An array:
            <code class="leafygreen-ui-1l06pbn">
             [ &lt; lower bound &gt;, &lt; upper bound &gt; ]
            </code>
            ,
           </p>
          </li>
          <li class="leafygreen-ui-d7p7b6">
           <p class="leafygreen-ui-1kp3ins">
            A string: either
            <code class="leafygreen-ui-1l06pbn">
             "full"
            </code>
            or
            <code class="leafygreen-ui-1l06pbn">
             "partition"
            </code>
            .
           </p>
          </li>
         </ul>
         <p class="leafygreen-ui-1kp3ins">
          If
          <code class="leafygreen-ui-1l06pbn">
           bounds
          </code>
          is an array:
         </p>
         <ul class="leafygreen-ui-rioki0">
          <li class="leafygreen-ui-d7p7b6">
           <p class="leafygreen-ui-1kp3ins">
            <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
             <span>
              <code class="leafygreen-ui-1l06pbn">
               $densify
              </code>
             </span>
            </a>
            adds documents spanning the range of
values within the specified bounds.
           </p>
          </li>
          <li class="leafygreen-ui-d7p7b6">
           <p class="leafygreen-ui-1kp3ins">
            The data type for the bounds must correspond to the data type
in the
            <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-field" target="_self">
             <span>
              field
             </span>
            </a>
            being densified.
           </p>
          </li>
          <li class="leafygreen-ui-d7p7b6">
           <p class="leafygreen-ui-1kp3ins">
            For behavior details, see
            <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-bounds-behavior" target="_self">
             <span>
              <code class="leafygreen-ui-1l06pbn">
               range.bounds
              </code>
              Behavior
              <!-- -->
              .
             </span>
            </a>
           </p>
          </li>
         </ul>
         <p class="leafygreen-ui-1kp3ins">
          If
          <code class="leafygreen-ui-1l06pbn">
           bounds
          </code>
          is
          <code class="leafygreen-ui-1l06pbn">
           "full"
          </code>
          :
         </p>
         <ul class="leafygreen-ui-rioki0">
          <li class="leafygreen-ui-d7p7b6">
           <p class="leafygreen-ui-1kp3ins">
            <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
             <span>
              <code class="leafygreen-ui-1l06pbn">
               $densify
              </code>
             </span>
            </a>
            adds documents spanning the full range of
values of the
            <code class="leafygreen-ui-1l06pbn">
             field
            </code>
            being densified.
           </p>
          </li>
         </ul>
         <p class="leafygreen-ui-1kp3ins">
          If
          <code class="leafygreen-ui-1l06pbn">
           bounds
          </code>
          is
          <code class="leafygreen-ui-1l06pbn">
           "partition"
          </code>
          :
         </p>
         <ul class="leafygreen-ui-rioki0">
          <li class="leafygreen-ui-d7p7b6">
           <p class="leafygreen-ui-1kp3ins">
            <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
             <span>
              <code class="leafygreen-ui-1l06pbn">
               $densify
              </code>
             </span>
            </a>
            adds documents to each partition,
similar to if you had run a
            <code class="leafygreen-ui-1l06pbn">
             full
            </code>
            range densification on
each partition individually.
           </p>
          </li>
         </ul>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-step" target="_self">
          <span>
           range.step
          </span>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Required
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <span class="leafygreen-ui-1qnjd6d" id="std-label-densify-step">
         </span>
         <p class="leafygreen-ui-1kp3ins">
          The amount to increment the
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-field" target="_self">
           <span>
            field
           </span>
          </a>
          value
in each document.
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
           <span>
            <code class="leafygreen-ui-1l06pbn">
             $densify
            </code>
           </span>
          </a>
          creates a new document for
each
          <code class="leafygreen-ui-1l06pbn">
           step
          </code>
          between the existing documents.
         </p>
         <p class="leafygreen-ui-1kp3ins">
          If
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-unit" target="_self">
           <span>
            range.unit
           </span>
          </a>
          is specified,
          <code class="leafygreen-ui-1l06pbn">
           step
          </code>
          must be an integer. Otherwise,
          <code class="leafygreen-ui-1l06pbn">
           step
          </code>
          can be any numeric
value.
         </p>
        </div>
       </div>
      </td>
     </tr>
     <tr class="leafygreen-ui-15dvrnp">
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-unit" target="_self">
          <span>
           range.unit
          </span>
         </a>
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         Required if
         <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-field" target="_self">
          <span>
           field
          </span>
         </a>
         is a date.
        </div>
       </div>
      </td>
      <td class="leafygreen-ui-1drjk7h">
       <div class="leafygreen-ui-1n4j8xf">
        <div>
         <span class="leafygreen-ui-1qnjd6d" id="std-label-densify-unit">
         </span>
         <p class="leafygreen-ui-1kp3ins">
          The unit to apply to the
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-step" target="_self">
           <span>
            step
           </span>
          </a>
          field when
incrementing date values in
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-field" target="_self">
           <span>
            field
            <!-- -->
            .
           </span>
          </a>
         </p>
         <p class="leafygreen-ui-1kp3ins">
          You can specify one of the following values for
          <code class="leafygreen-ui-1l06pbn">
           unit
          </code>
          as a string:
         </p>
         <ul class="leafygreen-ui-rioki0">
          <li class="leafygreen-ui-d7p7b6">
           <p class="leafygreen-ui-1kp3ins">
            <code class="leafygreen-ui-1l06pbn">
             millisecond
            </code>
           </p>
          </li>
          <li class="leafygreen-ui-d7p7b6">
           <p class="leafygreen-ui-1kp3ins">
            <code class="leafygreen-ui-1l06pbn">
             second
            </code>
           </p>
          </li>
          <li class="leafygreen-ui-d7p7b6">
           <p class="leafygreen-ui-1kp3ins">
            <code class="leafygreen-ui-1l06pbn">
             minute
            </code>
           </p>
          </li>
          <li class="leafygreen-ui-d7p7b6">
           <p class="leafygreen-ui-1kp3ins">
            <code class="leafygreen-ui-1l06pbn">
             hour
            </code>
           </p>
          </li>
          <li class="leafygreen-ui-d7p7b6">
           <p class="leafygreen-ui-1kp3ins">
            <code class="leafygreen-ui-1l06pbn">
             day
            </code>
           </p>
          </li>
          <li class="leafygreen-ui-d7p7b6">
           <p class="leafygreen-ui-1kp3ins">
            <code class="leafygreen-ui-1l06pbn">
             week
            </code>
           </p>
          </li>
          <li class="leafygreen-ui-d7p7b6">
           <p class="leafygreen-ui-1kp3ins">
            <code class="leafygreen-ui-1l06pbn">
             month
            </code>
           </p>
          </li>
          <li class="leafygreen-ui-d7p7b6">
           <p class="leafygreen-ui-1kp3ins">
            <code class="leafygreen-ui-1l06pbn">
             quarter
            </code>
           </p>
          </li>
          <li class="leafygreen-ui-d7p7b6">
           <p class="leafygreen-ui-1kp3ins">
            <code class="leafygreen-ui-1l06pbn">
             year
            </code>
           </p>
          </li>
         </ul>
         <p class="leafygreen-ui-1kp3ins">
          For an example, see
          <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-examples-time-series" target="_self">
           <span>
            Densify Time Series Data
            <!-- -->
            .
           </span>
          </a>
         </p>
        </div>
       </div>
      </td>
     </tr>
    </tbody>
   </table>
  </div>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Behavior and Restrictions
   <a class="headerlink leafygreen-ui-1kepx47" href="#behavior-and-restrictions" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="behavior-and-restrictions">
    </div>
   </a>
  </h2>
  <span class="leafygreen-ui-1qnjd6d" id="std-label-densify-field-restrictions">
  </span>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    <code class="leafygreen-ui-1l06pbn">
     field
    </code>
    Restrictions
    <a class="headerlink leafygreen-ui-1kepx47" href="#field-restrictions" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="field-restrictions">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    For documents that contain the specified
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-field" target="_self">
     <span>
      field
     </span>
    </a>
    ,
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
     <span>
      <code class="leafygreen-ui-1l06pbn">
       $densify
      </code>
     </span>
    </a>
    errors if:
   </p>
   <ul class="leafygreen-ui-rioki0">
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      Any document in the collection has a
      <code class="leafygreen-ui-1l06pbn">
       field
      </code>
      value  of type date and
the
      <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-unit" target="_self">
       <span>
        unit
       </span>
      </a>
      field is not specified.
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      Any document in the collection has a
      <code class="leafygreen-ui-1l06pbn">
       field
      </code>
      value  of type numeric
and the
      <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-unit" target="_self">
       <span>
        unit
       </span>
      </a>
      field is specified.
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      The
      <code class="leafygreen-ui-1l06pbn">
       field
      </code>
      name begins with
      <code class="leafygreen-ui-1l06pbn">
       $
      </code>
      . You must rename the field if
you want to densify it. To rename fields, use
      <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/project/#mongodb-pipeline-pipe.-project">
       <code class="leafygreen-ui-1l06pbn">
        $project
       </code>
       .
      </a>
     </p>
    </li>
   </ul>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-partition-by-fields-restrictions">
   </span>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    <code class="leafygreen-ui-1l06pbn">
     partitionByFields
    </code>
    Restrictions
    <a class="headerlink leafygreen-ui-1kepx47" href="#partitionbyfields-restrictions" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="partitionbyfields-restrictions">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
     <span>
      <code class="leafygreen-ui-1l06pbn">
       $densify
      </code>
     </span>
    </a>
    errors if any field name in the
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-partition-by-fields" target="_self">
     <span>
      partitionByFields
     </span>
    </a>
    array:
   </p>
   <ul class="leafygreen-ui-rioki0">
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      Evaluates to a non-string value.
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      Begins with
      <code class="leafygreen-ui-1l06pbn">
       $
      </code>
      .
     </p>
    </li>
   </ul>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-bounds-behavior">
   </span>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    <code class="leafygreen-ui-1l06pbn">
     range.bounds
    </code>
    Behavior
    <a class="headerlink leafygreen-ui-1kepx47" href="#range.bounds-behavior" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="range.bounds-behavior">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    If
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-bounds" target="_self">
     <span>
      range.bounds
     </span>
    </a>
    is an array:
   </p>
   <ul class="leafygreen-ui-rioki0">
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      The lower bound indicates the start value for the added
documents, irrespective of documents already in the collection.
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      The lower bound is inclusive.
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      The upper bound is exclusive.
     </p>
    </li>
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
       <span>
        <code class="leafygreen-ui-1l06pbn">
         $densify
        </code>
       </span>
      </a>
      does not filter out documents with
      <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#std-label-densify-field" target="_self">
       <span>
        field
       </span>
      </a>
      values outside of the specified
bounds.
     </p>
    </li>
   </ul>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Order of Output
    <a class="headerlink leafygreen-ui-1kepx47" href="#order-of-output" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="order-of-output">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
     <span>
      <code class="leafygreen-ui-1l06pbn">
       $densify
      </code>
     </span>
    </a>
    does not guarantee sort order of the documents
it outputs.
   </p>
   <p class="leafygreen-ui-1kp3ins">
    To guarantee sort order, use
    <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/sort/#mongodb-pipeline-pipe.-sort">
     <code class="leafygreen-ui-1l06pbn">
      $sort
     </code>
    </a>
    on the field you want
to sort by.
   </p>
  </section>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Examples
   <a class="headerlink leafygreen-ui-1kepx47" href="#examples" title="Permalink to this heading">
    <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
     <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
     </path>
     <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
     </path>
    </svg>
    <div class="css-1btu0w3 evvkmar0" id="examples">
    </div>
   </a>
  </h2>
  <span class="leafygreen-ui-1qnjd6d" id="std-label-densify-examples-time-series">
  </span>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Densify Time Series Data
    <a class="headerlink leafygreen-ui-1kepx47" href="#densify-time-series-data" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="densify-time-series-data">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    Create a
    <code class="leafygreen-ui-1l06pbn">
     weather
    </code>
    collection that contains temperature readings over
four hour intervals.
   </p>
   <script class="structured_data" type="application/ld+json">
    {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.weather.insertMany( [\n   {\n       \"metadata\": { \"sensorId\": 5578, \"type\": \"temperature\" },\n       \"timestamp\": ISODate(\"2021-05-18T00:00:00.000Z\"),\n       \"temp\": 12\n   },\n   {\n       \"metadata\": { \"sensorId\": 5578, \"type\": \"temperature\" },\n       \"timestamp\": ISODate(\"2021-05-18T04:00:00.000Z\"),\n       \"temp\": 11\n   },\n   {\n       \"metadata\": { \"sensorId\": 5578, \"type\": \"temperature\" },\n       \"timestamp\": ISODate(\"2021-05-18T08:00:00.000Z\"),\n       \"temp\": 11\n   },\n   {\n       \"metadata\": { \"sensorId\": 5578, \"type\": \"temperature\" },\n       \"timestamp\": ISODate(\"2021-05-18T12:00:00.000Z\"),\n       \"temp\": 12\n   }\n] )","programmingLanguage":"JavaScript"}
   </script>
   <div class="css-16lmvu9">
    <div class="leafygreen-ui-196mwvg">
     <div class="leafygreen-ui-1b1bvay">
      <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">weather</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">       <span class="lg-highlight-string">"metadata"</span>: <!-- -->{ <span class="lg-highlight-string">"sensorId"</span>: <span class="lg-highlight-number">5578</span>, <span class="lg-highlight-string">"type"</span>: <span class="lg-highlight-string">"temperature"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">       <span class="lg-highlight-string">"timestamp"</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-05-18T00:00:00.000Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">       <span class="lg-highlight-string">"temp"</span>: <span class="lg-highlight-number">12</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">       <span class="lg-highlight-string">"metadata"</span>: <!-- -->{ <span class="lg-highlight-string">"sensorId"</span>: <span class="lg-highlight-number">5578</span>, <span class="lg-highlight-string">"type"</span>: <span class="lg-highlight-string">"temperature"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">       <span class="lg-highlight-string">"timestamp"</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-05-18T04:00:00.000Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">       <span class="lg-highlight-string">"temp"</span>: <span class="lg-highlight-number">11</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">       <span class="lg-highlight-string">"metadata"</span>: <!-- -->{ <span class="lg-highlight-string">"sensorId"</span>: <span class="lg-highlight-number">5578</span>, <span class="lg-highlight-string">"type"</span>: <span class="lg-highlight-string">"temperature"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">       <span class="lg-highlight-string">"timestamp"</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-05-18T08:00:00.000Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">       <span class="lg-highlight-string">"temp"</span>: <span class="lg-highlight-number">11</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">       <span class="lg-highlight-string">"metadata"</span>: <!-- -->{ <span class="lg-highlight-string">"sensorId"</span>: <span class="lg-highlight-number">5578</span>, <span class="lg-highlight-string">"type"</span>: <span class="lg-highlight-string">"temperature"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">       <span class="lg-highlight-string">"timestamp"</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-05-18T12:00:00.000Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">       <span class="lg-highlight-string">"temp"</span>: <span class="lg-highlight-number">12</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</td></tr></tbody></table></code></pre>
      <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
       <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
        <div class="leafygreen-ui-xhlipt">
         <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
          <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
          </path>
         </svg>
        </div>
       </button>
      </div>
     </div>
    </div>
   </div>
   <p class="leafygreen-ui-1kp3ins">
    This example uses the
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
     <span>
      <code class="leafygreen-ui-1l06pbn">
       $densify
      </code>
     </span>
    </a>
    stage to fill in the gaps
between the four-hour intervals to achieve hourly granularity for the
data points:
   </p>
   <script class="structured_data" type="application/ld+json">
    {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.weather.aggregate( [\n   {\n      $densify: {\n         field: \"timestamp\",\n         range: {\n            step: 1,\n            unit: \"hour\",\n            bounds:[ ISODate(\"2021-05-18T00:00:00.000Z\"), ISODate(\"2021-05-18T08:00:00.000Z\") ]\n         }\n      }\n   }\n] )","programmingLanguage":"JavaScript"}
   </script>
   <div class="css-16lmvu9">
    <div class="leafygreen-ui-196mwvg">
     <div class="leafygreen-ui-1b1bvay">
      <pre class="leafygreen-ui-11itue3" tabindex="0"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">weather</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">$densify</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">field</span>: <span class="lg-highlight-string">"timestamp"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">range</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">            <span class="lg-highlight-attr">step</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">            <span class="lg-highlight-attr">unit</span>: <span class="lg-highlight-string">"hour"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">            <span class="lg-highlight-attr">bounds</span>:<!-- -->[ <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-05-18T00:00:00.000Z"</span>)<!-- -->, <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-05-18T08:00:00.000Z"</span>) ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</td></tr></tbody></table></code></pre>
      <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
       <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
        <div class="leafygreen-ui-xhlipt">
         <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
          <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
          </path>
         </svg>
        </div>
       </button>
      </div>
     </div>
    </div>
   </div>
   <p class="leafygreen-ui-1kp3ins">
    In the example:
   </p>
   <ul class="leafygreen-ui-rioki0">
    <li class="leafygreen-ui-d7p7b6">
     <p class="leafygreen-ui-1kp3ins">
      The
      <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
       <span>
        <code class="leafygreen-ui-1l06pbn">
         $densify
        </code>
       </span>
      </a>
      stage fills in the gaps of time in between the
recorded temperatures.
     </p>
     <ul class="leafygreen-ui-rioki0">
      <li class="leafygreen-ui-d7p7b6">
       <p class="leafygreen-ui-1kp3ins">
        <code class="leafygreen-ui-1l06pbn">
         field: "timestamp"
        </code>
        densifies the
        <code class="leafygreen-ui-1l06pbn">
         timestamp
        </code>
        field.
       </p>
      </li>
      <li class="leafygreen-ui-d7p7b6">
       <p class="leafygreen-ui-1kp3ins">
        <code class="leafygreen-ui-1l06pbn">
         range:
        </code>
       </p>
       <ul class="leafygreen-ui-rioki0">
        <li class="leafygreen-ui-d7p7b6">
         <p class="leafygreen-ui-1kp3ins">
          <code class="leafygreen-ui-1l06pbn">
           step: 1
          </code>
          increments the
          <code class="leafygreen-ui-1l06pbn">
           timestamp
          </code>
          field by 1 unit.
         </p>
        </li>
        <li class="leafygreen-ui-d7p7b6">
         <p class="leafygreen-ui-1kp3ins">
          <code class="leafygreen-ui-1l06pbn">
           unit: hour
          </code>
          densifies the
          <code class="leafygreen-ui-1l06pbn">
           timestamp
          </code>
          field by the hour.
         </p>
        </li>
        <li class="leafygreen-ui-d7p7b6">
         <p class="leafygreen-ui-1kp3ins">
          <code class="leafygreen-ui-1l06pbn">
           bounds: [ ISODate("2021-05-18T00:00:00.000Z"), ISODate("2021-05-18T08:00:00.000Z") ]
          </code>
          sets the range of time that is densified.
         </p>
        </li>
       </ul>
      </li>
     </ul>
    </li>
   </ul>
   <p class="leafygreen-ui-1kp3ins">
    In the following output, the
    <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
     <span>
      <code class="leafygreen-ui-1l06pbn">
       $densify
      </code>
     </span>
    </a>
    stage fills in the gaps of time
between the hours of
    <code class="leafygreen-ui-1l06pbn">
     00:00:00
    </code>
    and
    <code class="leafygreen-ui-1l06pbn">
     08:00:00
    </code>
    .
   </p>
   <script class="structured_data" type="application/ld+json">
    {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n  {\n    _id: ObjectId(\"618c207c63056cfad0ca4309\"),\n    metadata: { sensorId: 5578, type: 'temperature' },\n    timestamp: ISODate(\"2021-05-18T00:00:00.000Z\"),\n    temp: 12\n  },\n  { timestamp: ISODate(\"2021-05-18T01:00:00.000Z\") },\n  { timestamp: ISODate(\"2021-05-18T02:00:00.000Z\") },\n  { timestamp: ISODate(\"2021-05-18T03:00:00.000Z\") },\n  {\n    _id: ObjectId(\"618c207c63056cfad0ca430a\"),\n    metadata: { sensorId: 5578, type: 'temperature' },\n    timestamp: ISODate(\"2021-05-18T04:00:00.000Z\"),\n    temp: 11\n  },\n  { timestamp: ISODate(\"2021-05-18T05:00:00.000Z\") },\n  { timestamp: ISODate(\"2021-05-18T06:00:00.000Z\") },\n  { timestamp: ISODate(\"2021-05-18T07:00:00.000Z\") },\n  {\n    _id: ObjectId(\"618c207c63056cfad0ca430b\"),\n    metadata: { sensorId: 5578, type: 'temperature' },\n    timestamp: ISODate(\"2021-05-18T08:00:00.000Z\"),\n    temp: 11\n  }\n  {\n    _id: ObjectId(\"618c207c63056cfad0ca430c\"),\n    metadata: { sensorId: 5578, type: 'temperature' },\n    timestamp: ISODate(\"2021-05-18T12:00:00.000Z\"),\n    temp: 12\n  }\n]","programmingLanguage":"JavaScript"}
   </script>
   <div class="css-1lju8ps">
    <div class="leafygreen-ui-196mwvg">
     <div class="leafygreen-ui-1jheeh3">
      <pre class="leafygreen-ui-1453az5" tabindex="-1"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"618c207c63056cfad0ca4309"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">metadata</span>: <!-- -->{ <span class="lg-highlight-attr">sensorId</span>: <span class="lg-highlight-number">5578</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">'temperature'</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">timestamp</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-05-18T00:00:00.000Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">temp</span>: <span class="lg-highlight-number">12</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">  <!-- -->{ <span class="lg-highlight-attr">timestamp</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-05-18T01:00:00.000Z"</span>) }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">  <!-- -->{ <span class="lg-highlight-attr">timestamp</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-05-18T02:00:00.000Z"</span>) }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">  <!-- -->{ <span class="lg-highlight-attr">timestamp</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-05-18T03:00:00.000Z"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"618c207c63056cfad0ca430a"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">metadata</span>: <!-- -->{ <span class="lg-highlight-attr">sensorId</span>: <span class="lg-highlight-number">5578</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">'temperature'</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">timestamp</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-05-18T04:00:00.000Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">temp</span>: <span class="lg-highlight-number">11</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">  <!-- -->{ <span class="lg-highlight-attr">timestamp</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-05-18T05:00:00.000Z"</span>) }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">  <!-- -->{ <span class="lg-highlight-attr">timestamp</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-05-18T06:00:00.000Z"</span>) }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">  <!-- -->{ <span class="lg-highlight-attr">timestamp</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-05-18T07:00:00.000Z"</span>) }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"618c207c63056cfad0ca430b"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">metadata</span>: <!-- -->{ <span class="lg-highlight-attr">sensorId</span>: <span class="lg-highlight-number">5578</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">'temperature'</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">timestamp</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-05-18T08:00:00.000Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">temp</span>: <span class="lg-highlight-number">11</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">  <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"618c207c63056cfad0ca430c"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">metadata</span>: <!-- -->{ <span class="lg-highlight-attr">sensorId</span>: <span class="lg-highlight-number">5578</span>, <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">'temperature'</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">timestamp</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"2021-05-18T12:00:00.000Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">    <span class="lg-highlight-attr">temp</span>: <span class="lg-highlight-number">12</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">  }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">]</td></tr></tbody></table></code></pre>
     </div>
    </div>
   </div>
   <span class="leafygreen-ui-1qnjd6d" id="std-label-densify-examples-partitions">
   </span>
  </section>
  <section>
   <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
    Densifiction with Partitions
    <a class="headerlink leafygreen-ui-1kepx47" href="#densifiction-with-partitions" title="Permalink to this heading">
     <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
      <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
      </path>
      <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
      </path>
     </svg>
     <div class="css-1btu0w3 evvkmar0" id="densifiction-with-partitions">
     </div>
    </a>
   </h3>
   <p class="leafygreen-ui-1kp3ins">
    Create a
    <code class="leafygreen-ui-1l06pbn">
     coffee
    </code>
    collection that contains data for two
varieties of coffee beans:
   </p>
   <script class="structured_data" type="application/ld+json">
    {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.coffee.insertMany( [\n   {\n      \"altitude\": 600,\n      \"variety\": \"Arabica Typica\",\n      \"score\": 68.3\n   },\n   {\n      \"altitude\": 750,\n      \"variety\": \"Arabica Typica\",\n      \"score\": 69.5\n   },\n   {\n      \"altitude\": 950,\n      \"variety\": \"Arabica Typica\",\n      \"score\": 70.5\n   },\n   {\n      \"altitude\": 1250,\n      \"variety\": \"Gesha\",\n      \"score\": 88.15\n   },\n   {\n     \"altitude\": 1700,\n     \"variety\": \"Gesha\",\n     \"score\": 95.5,\n     \"price\": 1029\n   }\n] )","programmingLanguage":"JavaScript"}
   </script>
   <div class="css-16lmvu9">
    <div class="leafygreen-ui-196mwvg">
     <div class="leafygreen-ui-yzcs8i">
      <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">coffee</span>.<span class="lg-highlight-title lg-highlight-function">insertMany</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-string">"altitude"</span>: <span class="lg-highlight-number">600</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-string">"variety"</span>: <span class="lg-highlight-string">"Arabica Typica"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-string">"score"</span>: <span class="lg-highlight-number">68.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-string">"altitude"</span>: <span class="lg-highlight-number">750</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-string">"variety"</span>: <span class="lg-highlight-string">"Arabica Typica"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-string">"score"</span>: <span class="lg-highlight-number">69.5</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-string">"altitude"</span>: <span class="lg-highlight-number">950</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-string">"variety"</span>: <span class="lg-highlight-string">"Arabica Typica"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-string">"score"</span>: <span class="lg-highlight-number">70.5</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-string">"altitude"</span>: <span class="lg-highlight-number">1250</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-string">"variety"</span>: <span class="lg-highlight-string">"Gesha"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-string">"score"</span>: <span class="lg-highlight-number">88.15</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-string">"altitude"</span>: <span class="lg-highlight-number">1700</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-string">"variety"</span>: <span class="lg-highlight-string">"Gesha"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-string">"score"</span>: <span class="lg-highlight-number">95.5</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-string">"price"</span>: <span class="lg-highlight-number">1029</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</td></tr></tbody></table></code></pre>
      <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
       <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
        <div class="leafygreen-ui-xhlipt">
         <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
          <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
          </path>
         </svg>
        </div>
       </button>
      </div>
     </div>
    </div>
   </div>
   <section>
    <h4 class="contains-headerlink leafygreen-ui-1vzlt5f">
     Densify the Full Range of Values
     <a class="headerlink leafygreen-ui-1kepx47" href="#densify-the-full-range-of-values" title="Permalink to this heading">
      <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
       <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
       </path>
       <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
       </path>
      </svg>
      <div class="css-1btu0w3 evvkmar0" id="densify-the-full-range-of-values">
      </div>
     </a>
    </h4>
    <p class="leafygreen-ui-1kp3ins">
     This example uses
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
      <span>
       <code class="leafygreen-ui-1l06pbn">
        $densify
       </code>
      </span>
     </a>
     to densify the
     <code class="leafygreen-ui-1l06pbn">
      altitude
     </code>
     field for each coffee
     <code class="leafygreen-ui-1l06pbn">
      variety
     </code>
     :
    </p>
    <script class="structured_data" type="application/ld+json">
     {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.coffee.aggregate( [\n   {\n      $densify: {\n         field: \"altitude\",\n         partitionByFields: [ \"variety\" ],\n         range: {\n            bounds: \"full\",\n            step: 200\n         }\n      }\n   }\n] )","programmingLanguage":"JavaScript"}
    </script>
    <div class="css-16lmvu9">
     <div class="leafygreen-ui-196mwvg">
      <div class="leafygreen-ui-yzcs8i">
       <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">coffee</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">$densify</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">field</span>: <span class="lg-highlight-string">"altitude"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">partitionByFields</span>: <!-- -->[ <span class="lg-highlight-string">"variety"</span> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">range</span>: <!-- -->{</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">            <span class="lg-highlight-attr">bounds</span>: <span class="lg-highlight-string">"full"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">            <span class="lg-highlight-attr">step</span>: <span class="lg-highlight-number">200</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">         }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</td></tr></tbody></table></code></pre>
       <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
        <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
         <div class="leafygreen-ui-xhlipt">
          <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
           <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
           </path>
          </svg>
         </div>
        </button>
       </div>
      </div>
     </div>
    </div>
    <p class="leafygreen-ui-1kp3ins">
     The example aggregation:
    </p>
    <ul class="leafygreen-ui-rioki0">
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       Partitions the documents by
       <code class="leafygreen-ui-1l06pbn">
        variety
       </code>
       to create one grouping for
       <code class="leafygreen-ui-1l06pbn">
        Arabica Typica
       </code>
       and one for
       <code class="leafygreen-ui-1l06pbn">
        Gesha
       </code>
       coffee.
      </p>
     </li>
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       Specifies a
       <code class="leafygreen-ui-1l06pbn">
        full
       </code>
       range, meaning that the data is densified
across the full range of existing documents
       <em>
        for each partition
       </em>
       .
      </p>
     </li>
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       Specifies a
       <code class="leafygreen-ui-1l06pbn">
        step
       </code>
       of
       <code class="leafygreen-ui-1l06pbn">
        200
       </code>
       , meaning new documents are created
at
       <code class="leafygreen-ui-1l06pbn">
        altitude
       </code>
       intervals of
       <code class="leafygreen-ui-1l06pbn">
        200
       </code>
       .
      </p>
     </li>
    </ul>
    <p class="leafygreen-ui-1kp3ins">
     The aggregation outputs the following documents:
    </p>
    <script class="structured_data" type="application/ld+json">
     {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n   {\n     _id: ObjectId(\"618c031814fbe03334480475\"),\n     altitude: 600,\n     variety: 'Arabica Typica',\n     score: 68.3\n   },\n   {\n     _id: ObjectId(\"618c031814fbe03334480476\"),\n     altitude: 750,\n     variety: 'Arabica Typica',\n     score: 69.5\n   },\n   { variety: 'Arabica Typica', altitude: 800 },\n   {\n     _id: ObjectId(\"618c031814fbe03334480477\"),\n     altitude: 950,\n     variety: 'Arabica Typica',\n     score: 70.5\n   },\n   { variety: 'Gesha', altitude: 600 },\n   { variety: 'Gesha', altitude: 800 },\n   { variety: 'Gesha', altitude: 1000 },\n   { variety: 'Gesha', altitude: 1200 },\n   {\n     _id: ObjectId(\"618c031814fbe03334480478\"),\n     altitude: 1250,\n     variety: 'Gesha',\n     score: 88.15\n   },\n   { variety: 'Gesha', altitude: 1400 },\n   { variety: 'Gesha', altitude: 1600 },\n   {\n     _id: ObjectId(\"618c031814fbe03334480479\"),\n     altitude: 1700,\n     variety: 'Gesha',\n     score: 95.5,\n     price: 1029\n   },\n   { variety: 'Arabica Typica', altitude: 1000 },\n   { variety: 'Arabica Typica', altitude: 1200 },\n   { variety: 'Arabica Typica', altitude: 1400 },\n   { variety: 'Arabica Typica', altitude: 1600 }\n ]","programmingLanguage":"JavaScript"}
    </script>
    <div class="css-1lju8ps">
     <div class="leafygreen-ui-196mwvg">
      <div class="leafygreen-ui-1jheeh3">
       <pre class="leafygreen-ui-1453az5" tabindex="-1"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"618c031814fbe03334480475"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">600</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Arabica Typica'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">score</span>: <span class="lg-highlight-number">68.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"618c031814fbe03334480476"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">750</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Arabica Typica'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">score</span>: <span class="lg-highlight-number">69.5</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">   <!-- -->{ <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Arabica Typica'</span>, <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">800</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"618c031814fbe03334480477"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">950</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Arabica Typica'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">score</span>: <span class="lg-highlight-number">70.5</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">   <!-- -->{ <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Gesha'</span>, <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">600</span> }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">   <!-- -->{ <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Gesha'</span>, <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">800</span> }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">   <!-- -->{ <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Gesha'</span>, <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">1000</span> }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">   <!-- -->{ <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Gesha'</span>, <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">1200</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"618c031814fbe03334480478"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">1250</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Gesha'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">score</span>: <span class="lg-highlight-number">88.15</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">   <!-- -->{ <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Gesha'</span>, <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">1400</span> }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">   <!-- -->{ <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Gesha'</span>, <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">1600</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"618c031814fbe03334480479"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">1700</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Gesha'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">score</span>: <span class="lg-highlight-number">95.5</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">1029</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">   <!-- -->{ <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Arabica Typica'</span>, <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">1000</span> }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">   <!-- -->{ <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Arabica Typica'</span>, <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">1200</span> }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">   <!-- -->{ <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Arabica Typica'</span>, <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">1400</span> }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">   <!-- -->{ <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Arabica Typica'</span>, <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">1600</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr></tbody></table></code></pre>
      </div>
     </div>
    </div>
    <p class="leafygreen-ui-1kp3ins">
     This image visualizes the documents created with
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
      <span>
       <code class="leafygreen-ui-1l06pbn">
        $densify
       </code>
       :
      </span>
     </a>
    </p>
    <div class="css-y1v7l ej97su30">
     <div role="button" tabindex="-1">
      <div class="gatsby-image-wrapper gatsby-image-wrapper-constrained leafygreen-ui-12xaq6r" data-gatsby-image-wrapper="">
       <div style="max-width:1744px;display:block">
        <img alt="" aria-hidden="true" role="presentation" src="data:image/svg+xml;charset=utf-8,%3Csvg%20height='492'%20width='1744'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%3E%3C/svg%3E" style="max-width:100%;display:block;position:static"/>
       </div>
       <div aria-hidden="true" data-placeholder-image="" style="opacity:1;transition:opacity 500ms linear">
       </div>
       <img alt="State of the coffee collection after full-range densifiction" data-main-image="" decoding="async" height="492" loading="lazy" sizes="(min-width: 1744px) 1744px, 100vw" src="/docs/manual/static/57b73dd19140d1d03bc4cd05ea6b8b0c/8131d/densification-full-range.webp" srcset="/docs/manual/static/57b73dd19140d1d03bc4cd05ea6b8b0c/54d9f/densification-full-range.webp 436w,/docs/manual/static/57b73dd19140d1d03bc4cd05ea6b8b0c/0a43f/densification-full-range.webp 872w,/docs/manual/static/57b73dd19140d1d03bc4cd05ea6b8b0c/8131d/densification-full-range.webp 1744w" style="--border-color:#C1C7C6;opacity:0" width="1744"/>
       <noscript>
        <img alt="State of the coffee collection after full-range densifiction" data-gatsby-image-ssr="" data-main-image="" decoding="async" height="492" loading="lazy" sizes="(min-width: 1744px) 1744px, 100vw" src="/docs/manual/static/57b73dd19140d1d03bc4cd05ea6b8b0c/8131d/densification-full-range.webp" srcset="/docs/manual/static/57b73dd19140d1d03bc4cd05ea6b8b0c/54d9f/densification-full-range.webp 436w,/docs/manual/static/57b73dd19140d1d03bc4cd05ea6b8b0c/0a43f/densification-full-range.webp 872w,/docs/manual/static/57b73dd19140d1d03bc4cd05ea6b8b0c/8131d/densification-full-range.webp 1744w" style="--border-color:#C1C7C6;opacity:0" width="1744"/>
       </noscript>
       <script type="module">
        const t="undefined"!=typeof HTMLImageElement&&"loading"in HTMLImageElement.prototype;if(t){const t=document.querySelectorAll("img[data-main-image]");for(let e of t){e.dataset.src&&(e.setAttribute("src",e.dataset.src),e.removeAttribute("data-src")),e.dataset.srcset&&(e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset"));const t=e.parentNode.querySelectorAll("source[data-srcset]");for(let e of t)e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset");e.complete&&(e.style.opacity=1,e.parentNode.parentNode.querySelector("[data-placeholder-image]").style.opacity=0)}}
       </script>
      </div>
      <div class="css-19pi7x2 ej97su31" style="--color:#444">
       click to enlarge
      </div>
     </div>
    </div>
    <ul class="leafygreen-ui-rioki0">
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       The darker squares represent the original documents in the collection.
      </p>
     </li>
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       The lighter squares represent the documents created with
       <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
        <span>
         <code class="leafygreen-ui-1l06pbn">
          $densify
         </code>
         .
        </span>
       </a>
      </p>
     </li>
    </ul>
   </section>
   <section>
    <h4 class="contains-headerlink leafygreen-ui-1vzlt5f">
     Densify Values within Each Partition
     <a class="headerlink leafygreen-ui-1kepx47" href="#densify-values-within-each-partition" title="Permalink to this heading">
      <svg aria-label="Link Icon" class="leafygreen-ui-a30zj9" fill="none" height="12" role="img" viewbox="0 0 16 16" width="12" xmlns="http://www.w3.org/2000/svg">
       <path d="M6.039 9.953a3.596 3.596 0 0 1-.327-.38l1.45-1.445a1.553 1.553 0 0 0 2.496.423l2.885-2.87a1.57 1.57 0 0 0 .01-2.213 1.553 1.553 0 0 0-2.203-.01l-.379.377A.995.995 0 0 1 8.56 3.83a1.005 1.005 0 0 1 .006-1.418l.38-.377a3.542 3.542 0 0 1 5.024.023 3.58 3.58 0 0 1-.022 5.047l-2.884 2.871a3.542 3.542 0 0 1-5.025-.022Z" fill="currentColor">
       </path>
       <path d="M9.961 6.047c.12.12.228.248.327.38l-1.45 1.445a1.553 1.553 0 0 0-2.496-.423l-2.885 2.87a1.57 1.57 0 0 0-.01 2.213 1.553 1.553 0 0 0 2.203.01l.379-.377a.995.995 0 0 1 1.411.006 1.005 1.005 0 0 1-.006 1.418l-.38.377a3.542 3.542 0 0 1-5.024-.023 3.58 3.58 0 0 1 .022-5.047l2.884-2.871a3.542 3.542 0 0 1 5.025.022Z" fill="currentColor">
       </path>
      </svg>
      <div class="css-1btu0w3 evvkmar0" id="densify-values-within-each-partition">
      </div>
     </a>
    </h4>
    <p class="leafygreen-ui-1kp3ins">
     This example uses
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
      <span>
       <code class="leafygreen-ui-1l06pbn">
        $densify
       </code>
      </span>
     </a>
     to only densify gaps in the
     <code class="leafygreen-ui-1l06pbn">
      altitude
     </code>
     field within each
     <code class="leafygreen-ui-1l06pbn">
      variety
     </code>
     :
    </p>
    <script class="structured_data" type="application/ld+json">
     {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.coffee.aggregate( [\n   {\n      $densify: {\n         field: \"altitude\",\n         partitionByFields: [ \"variety\" ],\n         range: {\n            bounds: \"partition\",\n            step: 200\n         }\n      }\n   }\n] )","programmingLanguage":"JavaScript"}
    </script>
    <div class="css-16lmvu9">
     <div class="leafygreen-ui-196mwvg">
      <div class="leafygreen-ui-yzcs8i">
       <pre class="leafygreen-ui-11itue3" tabindex="-1"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">db.<span class="lg-highlight-property">coffee</span>.<span class="lg-highlight-title lg-highlight-function">aggregate</span>( <!-- -->[</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">$densify</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">field</span>: <span class="lg-highlight-string">"altitude"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">partitionByFields</span>: <!-- -->[ <span class="lg-highlight-string">"variety"</span> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">range</span>: <!-- -->{</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">            <span class="lg-highlight-attr">bounds</span>: <span class="lg-highlight-string">"partition"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">            <span class="lg-highlight-attr">step</span>: <span class="lg-highlight-number">200</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">         }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">] )</td></tr></tbody></table></code></pre>
       <div class="leafygreen-ui-1bqcprk" data-testid="leafygreen-code-panel">
        <button aria-disabled="false" aria-label="Copy" class="leafygreen-ui-1c6zwke" data-testid="code_copy-button" tabindex="0">
         <div class="leafygreen-ui-xhlipt">
          <svg aria-label="Copy Icon" class="leafygreen-ui-1st74h4" height="16" role="img" viewbox="0 0 16 16" width="16">
           <path clip-rule="evenodd" d="M1 5.71428V10.2857C1 11.2325 1.76751 12 2.71429 12H5.75V7.10957C5.75 6.54414 5.97724 6.00244 6.38065 5.60623L8.67403 3.35381C8.77447 3.25516 8.88376 3.16757 9 3.09182V2.71429C9 1.76751 8.23249 1 7.28571 1H5.8V4.42857C5.8 5.13865 5.22437 5.71428 4.51429 5.71428H1ZM9 4.78571L7.25654 6.49804C7.24689 6.50752 7.23749 6.5172 7.22834 6.52708C7.22208 6.53383 7.21594 6.54068 7.20991 6.54762C7.07504 6.70295 7 6.90234 7 7.10957V7.79762H9H10.0095C10.4829 7.79762 10.8667 7.41386 10.8667 6.94047V4H10.1505C9.92587 4 9.7102 4.0882 9.54992 4.24562L9 4.78571ZM4.86667 1H4.15053C3.92587 1 3.7102 1.0882 3.54992 1.24562L1.25654 3.49804C1.09244 3.65921 1 3.87957 1 4.10957V4.79762H4.00952C4.48291 4.79762 4.86667 4.41386 4.86667 3.94047V1ZM7 12V8.71428H9H10.5143C11.2244 8.71428 11.8 8.13865 11.8 7.42857V4H13.2857C14.2325 4 15 4.76751 15 5.71429V13.2857C15 14.2325 14.2325 15 13.2857 15H8.71429C7.76751 15 7 14.2325 7 13.2857V12Z" fill="currentColor" fill-rule="evenodd">
           </path>
          </svg>
         </div>
        </button>
       </div>
      </div>
     </div>
    </div>
    <p class="leafygreen-ui-1kp3ins">
     The example aggregation:
    </p>
    <ul class="leafygreen-ui-rioki0">
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       Partitions the documents by
       <code class="leafygreen-ui-1l06pbn">
        variety
       </code>
       to create one grouping for
       <code class="leafygreen-ui-1l06pbn">
        Arabica Typica
       </code>
       and one for
       <code class="leafygreen-ui-1l06pbn">
        Gesha
       </code>
       coffee.
      </p>
     </li>
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       Specifies a
       <code class="leafygreen-ui-1l06pbn">
        partition
       </code>
       range, meaning that the data is densified
within each partition.
      </p>
      <ul class="leafygreen-ui-rioki0">
       <li class="leafygreen-ui-d7p7b6">
        <p class="leafygreen-ui-1kp3ins">
         For the
         <code class="leafygreen-ui-1l06pbn">
          Arabica Typica
         </code>
         partition, the range is
         <code class="leafygreen-ui-1l06pbn">
          600
         </code>
         -
         <code class="leafygreen-ui-1l06pbn">
          950
         </code>
         .
        </p>
       </li>
       <li class="leafygreen-ui-d7p7b6">
        <p class="leafygreen-ui-1kp3ins">
         For the
         <code class="leafygreen-ui-1l06pbn">
          Gesha
         </code>
         partition, the range is
         <code class="leafygreen-ui-1l06pbn">
          1250
         </code>
         -
         <code class="leafygreen-ui-1l06pbn">
          1700
         </code>
         .
        </p>
       </li>
      </ul>
     </li>
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       Specifies a
       <code class="leafygreen-ui-1l06pbn">
        step
       </code>
       of
       <code class="leafygreen-ui-1l06pbn">
        200
       </code>
       , meaning new documents are created
at
       <code class="leafygreen-ui-1l06pbn">
        altitude
       </code>
       intervals of
       <code class="leafygreen-ui-1l06pbn">
        200
       </code>
       .
      </p>
     </li>
    </ul>
    <p class="leafygreen-ui-1kp3ins">
     The aggregation outputs the following documents:
    </p>
    <script class="structured_data" type="application/ld+json">
     {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"[\n   {\n     _id: ObjectId(\"618c031814fbe03334480475\"),\n     altitude: 600,\n     variety: 'Arabica Typica',\n     score: 68.3\n   },\n   {\n     _id: ObjectId(\"618c031814fbe03334480476\"),\n     altitude: 750,\n     variety: 'Arabica Typica',\n     score: 69.5\n   },\n   { variety: 'Arabica Typica', altitude: 800 },\n   {\n     _id: ObjectId(\"618c031814fbe03334480477\"),\n     altitude: 950,\n     variety: 'Arabica Typica',\n     score: 70.5\n   },\n   {\n     _id: ObjectId(\"618c031814fbe03334480478\"),\n     altitude: 1250,\n     variety: 'Gesha',\n     score: 88.15\n   },\n   { variety: 'Gesha', altitude: 1450 },\n   { variety: 'Gesha', altitude: 1650 },\n   {\n     _id: ObjectId(\"618c031814fbe03334480479\"),\n     altitude: 1700,\n     variety: 'Gesha',\n     score: 95.5,\n     price: 1029\n   }\n ]","programmingLanguage":"JavaScript"}
    </script>
    <div class="css-1lju8ps">
     <div class="leafygreen-ui-196mwvg">
      <div class="leafygreen-ui-1jheeh3">
       <pre class="leafygreen-ui-1453az5" tabindex="-1"><code class="lg-highlight-hljs-light javascript leafygreen-ui-9ybzas"><table class="leafygreen-ui-1tr4g10"><tbody><tr class=""><td class="leafygreen-ui-7razhx">[</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"618c031814fbe03334480475"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">600</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Arabica Typica'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">score</span>: <span class="lg-highlight-number">68.3</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"618c031814fbe03334480476"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">750</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Arabica Typica'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">score</span>: <span class="lg-highlight-number">69.5</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">   <!-- -->{ <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Arabica Typica'</span>, <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">800</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"618c031814fbe03334480477"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">950</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Arabica Typica'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">score</span>: <span class="lg-highlight-number">70.5</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"618c031814fbe03334480478"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">1250</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Gesha'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">score</span>: <span class="lg-highlight-number">88.15</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">   <!-- -->{ <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Gesha'</span>, <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">1450</span> }<!-- -->,</td></tr><tr class="leafygreen-ui-1wr1lm6"><td class="leafygreen-ui-7razhx">   <!-- -->{ <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Gesha'</span>, <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">1650</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-title lg-highlight-class">ObjectId</span>(<span class="lg-highlight-string">"618c031814fbe03334480479"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">altitude</span>: <span class="lg-highlight-number">1700</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">variety</span>: <span class="lg-highlight-string">'Gesha'</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">score</span>: <span class="lg-highlight-number">95.5</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">     <span class="lg-highlight-attr">price</span>: <span class="lg-highlight-number">1029</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }</td></tr><tr class=""><td class="leafygreen-ui-7razhx"> ]</td></tr></tbody></table></code></pre>
      </div>
     </div>
    </div>
    <p class="leafygreen-ui-1kp3ins">
     This image visualizes the documents created with
     <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
      <span>
       <code class="leafygreen-ui-1l06pbn">
        $densify
       </code>
       :
      </span>
     </a>
    </p>
    <div class="css-y1v7l ej97su30">
     <div role="button" tabindex="-1">
      <div class="gatsby-image-wrapper gatsby-image-wrapper-constrained leafygreen-ui-12xaq6r" data-gatsby-image-wrapper="">
       <div style="max-width:1624px;display:block">
        <img alt="" aria-hidden="true" role="presentation" src="data:image/svg+xml;charset=utf-8,%3Csvg%20height='466'%20width='1624'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%3E%3C/svg%3E" style="max-width:100%;display:block;position:static"/>
       </div>
       <div aria-hidden="true" data-placeholder-image="" style="opacity:1;transition:opacity 500ms linear">
       </div>
       <img alt="State of the coffee collection after partition range densification" data-main-image="" decoding="async" height="466" loading="lazy" sizes="(min-width: 1624px) 1624px, 100vw" src="/docs/manual/static/5edec880fd39c8e07681e582cbf98a13/9a463/densification-by-partition.webp" srcset="/docs/manual/static/5edec880fd39c8e07681e582cbf98a13/fc11e/densification-by-partition.webp 406w,/docs/manual/static/5edec880fd39c8e07681e582cbf98a13/a91d8/densification-by-partition.webp 812w,/docs/manual/static/5edec880fd39c8e07681e582cbf98a13/9a463/densification-by-partition.webp 1624w" style="--border-color:#C1C7C6;opacity:0" width="1624"/>
       <noscript>
        <img alt="State of the coffee collection after partition range densification" data-gatsby-image-ssr="" data-main-image="" decoding="async" height="466" loading="lazy" sizes="(min-width: 1624px) 1624px, 100vw" src="/docs/manual/static/5edec880fd39c8e07681e582cbf98a13/9a463/densification-by-partition.webp" srcset="/docs/manual/static/5edec880fd39c8e07681e582cbf98a13/fc11e/densification-by-partition.webp 406w,/docs/manual/static/5edec880fd39c8e07681e582cbf98a13/a91d8/densification-by-partition.webp 812w,/docs/manual/static/5edec880fd39c8e07681e582cbf98a13/9a463/densification-by-partition.webp 1624w" style="--border-color:#C1C7C6;opacity:0" width="1624"/>
       </noscript>
       <script type="module">
        const t="undefined"!=typeof HTMLImageElement&&"loading"in HTMLImageElement.prototype;if(t){const t=document.querySelectorAll("img[data-main-image]");for(let e of t){e.dataset.src&&(e.setAttribute("src",e.dataset.src),e.removeAttribute("data-src")),e.dataset.srcset&&(e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset"));const t=e.parentNode.querySelectorAll("source[data-srcset]");for(let e of t)e.setAttribute("srcset",e.dataset.srcset),e.removeAttribute("data-srcset");e.complete&&(e.style.opacity=1,e.parentNode.parentNode.querySelector("[data-placeholder-image]").style.opacity=0)}}
       </script>
      </div>
      <div class="css-19pi7x2 ej97su31" style="--color:#444">
       click to enlarge
      </div>
     </div>
    </div>
    <ul class="leafygreen-ui-rioki0">
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       The darker squares represent the original documents in the collection.
      </p>
     </li>
     <li class="leafygreen-ui-d7p7b6">
      <p class="leafygreen-ui-1kp3ins">
       The lighter squares represent the documents created with
       <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="#mongodb-pipeline-pipe.-densify" target="_self">
        <span>
         <code class="leafygreen-ui-1l06pbn">
          $densify
         </code>
         .
        </span>
       </a>
      </p>
     </li>
    </ul>
   </section>
  </section>
 </section>
</section>
