<section>
 <h1 class="contains-headerlink leafygreen-ui-41fr9s" weight="medium">
  Migrate Data into a Time Series Collection
  <a class="headerlink leafygreen-ui-1kepx47" href="#migrate-data-into-a-time-series-collection" 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="migrate-data-into-a-time-series-collection">
   </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="#about-this-task" target="_self">
     <span>
      About this Task
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#before-you-begin" target="_self">
     <span>
      Before you Begin
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#steps" target="_self">
     <span>
      Steps
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#optional.-create-a-metadata-field." target="_self">
     <span>
      Optional. Create a metadata field.
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-x9koo9" href="#create-your-time-series-collection-and-insert-your-data." target="_self">
     <span>
      Create your time series collection and insert your data.
     </span>
    </a>
   </li>
   <li class="leafygreen-ui-1jqtqlb">
    <a class="lg-ui-0001 leafygreen-ui-cpmeq5" href="#next-steps" target="_self">
     <span>
      Next Steps
     </span>
    </a>
   </li>
  </ul>
 </div>
 <p class="leafygreen-ui-1kp3ins">
  This page describes how to migrate data into a time series collection
using an
  <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/aggregation-pipeline/#std-label-aggregation-pipeline">
   aggregation pipeline
  </a>
  .
Alternatively, to learn how to migrate data into a time series
collection using MongoDB Relational Migrator, see
  <a class="lg-ui-0001 leafygreen-ui-fgcsv5" href="https://www.mongodb.com/docs/relational-migrator/mapping-rules/mapping-rule-options/time-series/" target="_self">
   <span>
    Configure a Time
Series Collection with Relational Migrator
   </span>
  </a>
  .
 </p>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   About this Task
   <a class="headerlink leafygreen-ui-1kepx47" href="#about-this-task" 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="about-this-task">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   Starting in MongoDB version 7.0, you can use the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/out/#mongodb-pipeline-pipe.-out">
    <code class="leafygreen-ui-1l06pbn">
     $out
    </code>
   </a>
   aggregation stage to migrate data from an existing collection into a
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/timeseries-collections/#std-label-manual-timeseries-collection">
    time series collection
   </a>
   . If your
collection stores data that you want to compare across time intervals,
use a time series collection to improve performance and storage. For more
information on the benefits of time series collections, see
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/timeseries-collections/#std-label-manual-timeseries-collection">
    Time Series Collections
    <!-- -->
    .
   </a>
  </p>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Before you Begin
   <a class="headerlink leafygreen-ui-1kepx47" href="#before-you-begin" 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="before-you-begin">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   Consider a
   <code class="leafygreen-ui-1l06pbn">
    weatherdata
   </code>
   collection that contains time and metadata information:
  </p>
  <script class="structured_data" type="application/ld+json">
   {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.weatherdata.insertOne(\n   {\n      _id: ObjectId(\"5553a998e4b02cf7151190b8\"),\n      st: \"x+47600-047900\",\n      ts: ISODate(\"1984-03-05T13:00:00Z\"),\n      position: {\n         type: \"Point\",\n         coordinates: [ -47.9, 47.6 ]\n      },\n      elevation: 9999,\n      callLetters: \"VCSZ\",\n      qualityControlProcess: \"V020\",\n      dataSource: \"4\",\n      type: \"FM-13\",\n      airTemperature: { value: -3.1, quality: \"1\" },\n      dewPoint: { value: 999.9, quality : \"9\" },\n      pressure: { value: 1015.3, quality: \"1\" },\n      wind: {\n         direction: { angle: 999, quality: \"9\" },\n         type: \"9\",\n         speed: { rate: 999.9, quality: \"9\" }\n      },\n      visibility: {\n         distance: { value: 999999, quality : \"9\" },\n         variability: { value: \"N\", quality: \"9\" }\n      },\n      skyCondition: {\n         ceilingHeight: { value: 99999, quality: \"9\", determination: \"9\" },\n         cavok: \"N\"\n      },\n      sections: [ \"AG1\" ],\n      precipitationEstimatedObservation: {\n         discrepancy: \"2\",\n         estimatedWaterDepth: 999\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">weatherdata</span>.<span class="lg-highlight-title lg-highlight-function">insertOne</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">"5553a998e4b02cf7151190b8"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">st</span>: <span class="lg-highlight-string">"x+47600-047900"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">ts</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"1984-03-05T13:00:00Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">position</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"Point"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">coordinates</span>: <!-- -->[ <!-- -->-<span class="lg-highlight-number">47.9</span>, <span class="lg-highlight-number">47.6</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">elevation</span>: <span class="lg-highlight-number">9999</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">callLetters</span>: <span class="lg-highlight-string">"VCSZ"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">qualityControlProcess</span>: <span class="lg-highlight-string">"V020"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">dataSource</span>: <span class="lg-highlight-string">"4"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"FM-13"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">airTemperature</span>: <!-- -->{ <span class="lg-highlight-attr">value</span>: <!-- -->-<span class="lg-highlight-number">3.1</span>, <span class="lg-highlight-attr">quality</span>: <span class="lg-highlight-string">"1"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">dewPoint</span>: <!-- -->{ <span class="lg-highlight-attr">value</span>: <span class="lg-highlight-number">999.9</span>, <!-- -->quality <!-- -->: <span class="lg-highlight-string">"9"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">pressure</span>: <!-- -->{ <span class="lg-highlight-attr">value</span>: <span class="lg-highlight-number">1015.3</span>, <span class="lg-highlight-attr">quality</span>: <span class="lg-highlight-string">"1"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">wind</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">direction</span>: <!-- -->{ <span class="lg-highlight-attr">angle</span>: <span class="lg-highlight-number">999</span>, <span class="lg-highlight-attr">quality</span>: <span class="lg-highlight-string">"9"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"9"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">speed</span>: <!-- -->{ <span class="lg-highlight-attr">rate</span>: <span class="lg-highlight-number">999.9</span>, <span class="lg-highlight-attr">quality</span>: <span class="lg-highlight-string">"9"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">visibility</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">distance</span>: <!-- -->{ <span class="lg-highlight-attr">value</span>: <span class="lg-highlight-number">999999</span>, <!-- -->quality <!-- -->: <span class="lg-highlight-string">"9"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">variability</span>: <!-- -->{ <span class="lg-highlight-attr">value</span>: <span class="lg-highlight-string">"N"</span>, <span class="lg-highlight-attr">quality</span>: <span class="lg-highlight-string">"9"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">skyCondition</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">ceilingHeight</span>: <!-- -->{ <span class="lg-highlight-attr">value</span>: <span class="lg-highlight-number">99999</span>, <span class="lg-highlight-attr">quality</span>: <span class="lg-highlight-string">"9"</span>, <span class="lg-highlight-attr">determination</span>: <span class="lg-highlight-string">"9"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">cavok</span>: <span class="lg-highlight-string">"N"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">      }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">sections</span>: <!-- -->[ <span class="lg-highlight-string">"AG1"</span> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">precipitationEstimatedObservation</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">discrepancy</span>: <span class="lg-highlight-string">"2"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">estimatedWaterDepth</span>: <span class="lg-highlight-number">999</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></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>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Steps
   <a class="headerlink leafygreen-ui-1kepx47" href="#steps" 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="steps">
    </div>
   </a>
  </h2>
  <script class="structured_data" type="application/ld+json">
   {"@context":"https://schema.org","@type":"HowTo","steps":[{"@type":"HowToStep","text":"If your collection does not include a specific field that contains\nall metadata, transform your data to define one.The following pipeline stages add a metaData field and use\n$project to include or exclude the remaining fields in\nthe document. In this example, the metaData field becomes the\nmetaField of the time series collection that you create.Choosing the right field as your time series metaField optimizes\nboth storage and query performance. For more information on\nmetaField selection and best practices, see\nmetaFields.","name":"Optional. Create a metadata field."},{"@type":"HowToStep","text":"The example below performs the following operations:Uses the $addFields aggregation stage to add a metaData field to\nyour weather_data collection.Uses the $out aggregation stage with the\ntimeseries option to create a weathernew time series\ncollection in the mydatabase database.Defines the metaField of your weathernew collection\nas the metaData field.Defines the timeField of your weathernew collection\nas the ts field.The timeField of a time series collection must be a date type.For the aggregation stage syntax, see\n$out. For a full explanation of the time series\noptions, see the Time Series Field Reference.","name":"Create your time series collection and insert your data."}],"name":"Steps","image":"https://webimages.mongodb.com/_com_assets/cms/kuyj2focmkbxv7gh3-stacked_default_slate_blue.svg?auto=format%252Ccompress"}
  </script>
  <div class="css-qum8nr eccljxs0">
   <div class="css-vq8pj5 e1ckbxcu1">
    <div class="css-18fui5z e1ckbxcu0">
     <div class="css-18jxsvu e1ckbxcu2">
      1
     </div>
    </div>
    <div class="css-clrhqf">
     <section>
      <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
       Optional. Create a metadata field.
       <a class="headerlink leafygreen-ui-1kepx47" href="#optional.-create-a-metadata-field." 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="optional.-create-a-metadata-field.">
        </div>
       </a>
      </h3>
      <p class="leafygreen-ui-1kp3ins">
       If your collection does not include a specific field that contains
all metadata, transform your data to define one.
      </p>
      <p class="leafygreen-ui-1kp3ins">
       The following pipeline stages add a
       <code class="leafygreen-ui-1l06pbn">
        metaData
       </code>
       field and 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>
       to include or exclude the remaining fields in
the document. In this example, the
       <code class="leafygreen-ui-1l06pbn">
        metaData
       </code>
       field becomes the
       <code class="leafygreen-ui-1l06pbn">
        metaField
       </code>
       of the time series collection that you create.
      </p>
      <div class="leafygreen-ui-15mdk4" role="note">
       <h2 class="leafygreen-ui-6n7b7d">
        Note
       </h2>
       <div class="leafygreen-ui-9mycqc">
        <p class="leafygreen-ui-1kp3ins">
         Choosing the right field as your time series
         <code class="leafygreen-ui-1l06pbn">
          metaField
         </code>
         optimizes
both storage and query performance. For more information on
         <code class="leafygreen-ui-1l06pbn">
          metaField
         </code>
         selection and best practices, see
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/timeseries-collections/#std-label-timeseries-collections-metafield">
          metaFields
          <!-- -->
          .
         </a>
        </p>
       </div>
      </div>
      <script class="structured_data" type="application/ld+json">
       {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"{ $addFields: {\n      metaData: {\n      st: \"$st\",\n      position: \"$position\",\n      elevation: \"$elevation\",\n      callLetters: \"$callLetters\",\n      qualityControlProcess: \"$qualityControlProcess\",\n      type: \"$type\"\n      }\n   },\n},\n{ $project: {\n      _id: 1,\n      ts: 1,\n      metaData: 1,\n      dataSource: 1,\n      airTemperature: 1,\n      dewPoint: 1,\n      pressure: 1,\n      wind: 1,\n      visibility: 1,\n      skyCondition: 1,\n      sections: 1,\n      precipitationEstimatedObservation: 1\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">{ <span class="lg-highlight-attr">$addFields</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">metaData</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">st</span>: <span class="lg-highlight-string">"$st"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">position</span>: <span class="lg-highlight-string">"$position"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">elevation</span>: <span class="lg-highlight-string">"$elevation"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">callLetters</span>: <span class="lg-highlight-string">"$callLetters"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">qualityControlProcess</span>: <span class="lg-highlight-string">"$qualityControlProcess"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"$type"</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">{ <span class="lg-highlight-attr">$project</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">ts</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">metaData</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">dataSource</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">airTemperature</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">dewPoint</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">pressure</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">wind</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">visibility</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">skyCondition</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">sections</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">precipitationEstimatedObservation</span>: <span class="lg-highlight-number">1</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>
     </section>
    </div>
   </div>
   <div class="css-vq8pj5 e1ckbxcu1">
    <div class="css-18fui5z e1ckbxcu0">
     <div class="css-18jxsvu e1ckbxcu2">
      2
     </div>
    </div>
    <div class="css-clrhqf">
     <section>
      <h3 class="contains-headerlink leafygreen-ui-15ajumo" weight="medium">
       Create your time series collection and insert your data.
       <a class="headerlink leafygreen-ui-1kepx47" href="#create-your-time-series-collection-and-insert-your-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="create-your-time-series-collection-and-insert-your-data.">
        </div>
       </a>
      </h3>
      <p class="leafygreen-ui-1kp3ins">
       The example below performs the following operations:
      </p>
      <ul class="leafygreen-ui-rioki0">
       <li class="leafygreen-ui-d7p7b6">
        <p class="leafygreen-ui-1kp3ins">
         Uses the
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/addFields/#mongodb-pipeline-pipe.-addFields">
          <code class="leafygreen-ui-1l06pbn">
           $addFields
          </code>
         </a>
         aggregation stage to add a
         <code class="leafygreen-ui-1l06pbn">
          metaData
         </code>
         field to
your
         <code class="leafygreen-ui-1l06pbn">
          weather_data
         </code>
         collection.
        </p>
       </li>
       <li class="leafygreen-ui-d7p7b6">
        <p class="leafygreen-ui-1kp3ins">
         Uses the
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/out/#mongodb-pipeline-pipe.-out">
          <code class="leafygreen-ui-1l06pbn">
           $out
          </code>
         </a>
         aggregation stage with the
         <code class="leafygreen-ui-1l06pbn">
          timeseries
         </code>
         option to create a
         <code class="leafygreen-ui-1l06pbn">
          weathernew
         </code>
         time series
collection in the
         <code class="leafygreen-ui-1l06pbn">
          mydatabase
         </code>
         database.
        </p>
       </li>
       <li class="leafygreen-ui-d7p7b6">
        <p class="leafygreen-ui-1kp3ins">
         Defines the
         <code class="leafygreen-ui-1l06pbn">
          metaField
         </code>
         of your
         <code class="leafygreen-ui-1l06pbn">
          weathernew
         </code>
         collection
as the
         <code class="leafygreen-ui-1l06pbn">
          metaData
         </code>
         field.
        </p>
       </li>
       <li class="leafygreen-ui-d7p7b6">
        <p class="leafygreen-ui-1kp3ins">
         Defines the
         <code class="leafygreen-ui-1l06pbn">
          timeField
         </code>
         of your
         <code class="leafygreen-ui-1l06pbn">
          weathernew
         </code>
         collection
as the
         <code class="leafygreen-ui-1l06pbn">
          ts
         </code>
         field.
        </p>
       </li>
      </ul>
      <div class="leafygreen-ui-15mdk4" role="note">
       <h2 class="leafygreen-ui-6n7b7d">
        Note
       </h2>
       <div class="leafygreen-ui-9mycqc">
        <p class="leafygreen-ui-1kp3ins">
         The
         <code class="leafygreen-ui-1l06pbn">
          timeField
         </code>
         of a time series collection must be a
         <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/bson-types/#std-label-document-bson-type-date">
          date
         </a>
         type.
        </p>
       </div>
      </div>
      <script class="structured_data" type="application/ld+json">
       {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.weather_data.aggregate( [\n  {\n     $addFields: {\n       metaData: {\n         st: \"$st\",\n         position: \"$position\",\n         elevation: \"$elevation\",\n         callLetters: \"$callLetters\",\n         qualityControlProcess: \"$qualityControlProcess\",\n         type: \"$type\"\n       }\n     },\n  }, {\n     $project: {\n        _id: 1,\n        ts: 1,\n        metaData: 1,\n        dataSource: 1,\n        airTemperature: 1,\n        dewPoint: 1,\n        pressure: 1,\n        wind: 1,\n        visibility: 1,\n        skyCondition: 1,\n        sections: 1,\n        precipitationEstimatedObservation: 1\n     }\n  }, {\n     $out: {\n       db: \"mydatabase\",\n       coll: \"weathernew\",\n       timeseries: {\n         timeField: \"ts\",\n         metaField: \"metaData\"\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_data</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">$addFields</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">       <span class="lg-highlight-attr">metaData</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">st</span>: <span class="lg-highlight-string">"$st"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">position</span>: <span class="lg-highlight-string">"$position"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">elevation</span>: <span class="lg-highlight-string">"$elevation"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">callLetters</span>: <span class="lg-highlight-string">"$callLetters"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">qualityControlProcess</span>: <span class="lg-highlight-string">"$qualityControlProcess"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"$type"</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">     <span class="lg-highlight-attr">$project</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">        <span class="lg-highlight-attr">_id</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">        <span class="lg-highlight-attr">ts</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">        <span class="lg-highlight-attr">metaData</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">        <span class="lg-highlight-attr">dataSource</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">        <span class="lg-highlight-attr">airTemperature</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">        <span class="lg-highlight-attr">dewPoint</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">        <span class="lg-highlight-attr">pressure</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">        <span class="lg-highlight-attr">wind</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">        <span class="lg-highlight-attr">visibility</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">        <span class="lg-highlight-attr">skyCondition</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">        <span class="lg-highlight-attr">sections</span>: <span class="lg-highlight-number">1</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">        <span class="lg-highlight-attr">precipitationEstimatedObservation</span>: <span class="lg-highlight-number">1</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">$out</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">       <span class="lg-highlight-attr">db</span>: <span class="lg-highlight-string">"mydatabase"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">       <span class="lg-highlight-attr">coll</span>: <span class="lg-highlight-string">"weathernew"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">       <span class="lg-highlight-attr">timeseries</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">timeField</span>: <span class="lg-highlight-string">"ts"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">metaField</span>: <span class="lg-highlight-string">"metaData"</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">
       For the aggregation stage syntax, see
       <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/operator/aggregation/out/#mongodb-pipeline-pipe.-out">
        <code class="leafygreen-ui-1l06pbn">
         $out
        </code>
       </a>
       . For a full explanation of the time series
options, see the
       <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/timeseries/timeseries-procedures/#std-label-time-series-fields">
        Time Series Field Reference
        <!-- -->
        .
       </a>
      </p>
     </section>
    </div>
   </div>
  </div>
  <p class="leafygreen-ui-1kp3ins">
   After you run this aggregation pipeline, you can use
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/reference/method/db.collection.findOne/#mongodb-method-db.collection.findOne">
    <code class="leafygreen-ui-1l06pbn">
     findOne()
    </code>
   </a>
   to view a document in your
   <code class="leafygreen-ui-1l06pbn">
    weathernew
   </code>
   time series collection:
  </p>
  <script class="structured_data" type="application/ld+json">
   {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"db.weathernew.findOne()","programmingLanguage":"JavaScript"}
  </script>
  <div class="css-16lmvu9">
   <div class="leafygreen-ui-196mwvg">
    <div class="leafygreen-ui-yzcs8i">
     <pre class="leafygreen-ui-1q4bxgx" 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">weathernew</span>.<span class="lg-highlight-title lg-highlight-function">findOne</span>(<!-- -->)</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 operation returns the following document:
  </p>
  <script class="structured_data" type="application/ld+json">
   {"@context":"https://schema.org","@type":"SoftwareSourceCode","codeSampleType":"code snippet","text":"   {\n      _id: ObjectId(\"5553a998e4b02cf7151190b8\"),\n      ts: ISODate(\"1984-03-05T13:00:00Z\"),\n      metaData: {\n         st: \"x+47600-047900\",\n         position: {\n            type: \"Point\",\n            coordinates: [ -47.9, 47.6 ]\n         },\n         elevation: 9999,\n         callLetters: \"VCSZ\",\n         qualityControlProcess: \"V020\",\n         type: \"FM-13\"\n      },\n      dataSource: \"4\",\n      airTemperature: { value: -3.1, quality: \"1\" },\n      dewPoint: { value: 999.9, quality: \"9\" },\n      pressure: { value: 1015.3, quality: \"1\" },\n      wind: {\n         direction: { angle: 999, quality: \"9\" },\n         type: \"9\",\n         speed: { rate: 999.9, quality: \"9\" }\n      },\n      visibility: {\n         distance: { value: 999999, quality: \"9\" },\n         variability: { value: \"N\", quality: \"9\" }\n      },\n      skyCondition: {\n         ceilingHeight: { value: 99999, quality: \"9\", determination: \"9\" },\n         cavok: \"N\"\n      },\n      sections: [ \"AG1\" ],\n      precipitationEstimatedObservation: { discrepancy: \"2\", estimatedWaterDepth: 999 }\n   }","programmingLanguage":"JavaScript"}
  </script>
  <div class="css-1lju8ps">
   <div class="leafygreen-ui-196mwvg">
    <div class="leafygreen-ui-tyg50d">
     <pre class="leafygreen-ui-1453az5" 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">   <!-- -->{</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">"5553a998e4b02cf7151190b8"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">ts</span>: <span class="lg-highlight-title lg-highlight-class">ISODate</span>(<span class="lg-highlight-string">"1984-03-05T13:00:00Z"</span>)<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">metaData</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">st</span>: <span class="lg-highlight-string">"x+47600-047900"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">position</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">            <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"Point"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">            <span class="lg-highlight-attr">coordinates</span>: <!-- -->[ <!-- -->-<span class="lg-highlight-number">47.9</span>, <span class="lg-highlight-number">47.6</span> ]</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">elevation</span>: <span class="lg-highlight-number">9999</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">callLetters</span>: <span class="lg-highlight-string">"VCSZ"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">qualityControlProcess</span>: <span class="lg-highlight-string">"V020"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"FM-13"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">      }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">dataSource</span>: <span class="lg-highlight-string">"4"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">airTemperature</span>: <!-- -->{ <span class="lg-highlight-attr">value</span>: <!-- -->-<span class="lg-highlight-number">3.1</span>, <span class="lg-highlight-attr">quality</span>: <span class="lg-highlight-string">"1"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">dewPoint</span>: <!-- -->{ <span class="lg-highlight-attr">value</span>: <span class="lg-highlight-number">999.9</span>, <span class="lg-highlight-attr">quality</span>: <span class="lg-highlight-string">"9"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">pressure</span>: <!-- -->{ <span class="lg-highlight-attr">value</span>: <span class="lg-highlight-number">1015.3</span>, <span class="lg-highlight-attr">quality</span>: <span class="lg-highlight-string">"1"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">wind</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">direction</span>: <!-- -->{ <span class="lg-highlight-attr">angle</span>: <span class="lg-highlight-number">999</span>, <span class="lg-highlight-attr">quality</span>: <span class="lg-highlight-string">"9"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">type</span>: <span class="lg-highlight-string">"9"</span>,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">speed</span>: <!-- -->{ <span class="lg-highlight-attr">rate</span>: <span class="lg-highlight-number">999.9</span>, <span class="lg-highlight-attr">quality</span>: <span class="lg-highlight-string">"9"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">visibility</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">distance</span>: <!-- -->{ <span class="lg-highlight-attr">value</span>: <span class="lg-highlight-number">999999</span>, <span class="lg-highlight-attr">quality</span>: <span class="lg-highlight-string">"9"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">variability</span>: <!-- -->{ <span class="lg-highlight-attr">value</span>: <span class="lg-highlight-string">"N"</span>, <span class="lg-highlight-attr">quality</span>: <span class="lg-highlight-string">"9"</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">skyCondition</span>: <!-- -->{</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">ceilingHeight</span>: <!-- -->{ <span class="lg-highlight-attr">value</span>: <span class="lg-highlight-number">99999</span>, <span class="lg-highlight-attr">quality</span>: <span class="lg-highlight-string">"9"</span>, <span class="lg-highlight-attr">determination</span>: <span class="lg-highlight-string">"9"</span> }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">         <span class="lg-highlight-attr">cavok</span>: <span class="lg-highlight-string">"N"</span></td></tr><tr class=""><td class="leafygreen-ui-7razhx">      }<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">sections</span>: <!-- -->[ <span class="lg-highlight-string">"AG1"</span> ]<!-- -->,</td></tr><tr class=""><td class="leafygreen-ui-7razhx">      <span class="lg-highlight-attr">precipitationEstimatedObservation</span>: <!-- -->{ <span class="lg-highlight-attr">discrepancy</span>: <span class="lg-highlight-string">"2"</span>, <span class="lg-highlight-attr">estimatedWaterDepth</span>: <span class="lg-highlight-number">999</span> }</td></tr><tr class=""><td class="leafygreen-ui-7razhx">   }</td></tr></tbody></table></code></pre>
    </div>
   </div>
  </div>
 </section>
 <section>
  <h2 class="contains-headerlink leafygreen-ui-19f71ei" weight="medium">
   Next Steps
   <a class="headerlink leafygreen-ui-1kepx47" href="#next-steps" 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="next-steps">
    </div>
   </a>
  </h2>
  <p class="leafygreen-ui-1kp3ins">
   If your original collection had secondary indexes, manually recreate
them now.
  </p>
  <p class="leafygreen-ui-1kp3ins">
   If your time series collection includes
   <code class="leafygreen-ui-1l06pbn">
    timeField
   </code>
   values before
   <code class="leafygreen-ui-1l06pbn">
    1970-01-01T00:00:00.000Z
   </code>
   or after
   <code class="leafygreen-ui-1l06pbn">
    2038-01-19T03:14:07.000Z
   </code>
   ,
MongoDB logs a warning and disables some query optimizations that make
use of the
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/timeseries-collections/#std-label-manual-timeseries-internal-index">
    internal clustered index
   </a>
   . To regain query performance and
resolve the log warning,
   <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/timeseries/timeseries-secondary-index/#std-label-timeseries-add-secondary-index">
    create a secondary index
   </a>
   on the
   <code class="leafygreen-ui-1l06pbn">
    timeField
   </code>
   .
  </p>
  <div class="leafygreen-ui-13vw3ie" role="note">
   <h2 class="leafygreen-ui-1fn4p2b">
    Tip
   </h2>
   <h3 class="leafygreen-ui-144d5kf">
    <strong>
     See also:
    </strong>
   </h3>
   <div class="leafygreen-ui-9mycqc">
    <p class="leafygreen-ui-1kp3ins">
     <a class="leafygreen-ui-tqgtui" href="/docs/manual/core/timeseries/timeseries-secondary-index/#std-label-timeseries-add-secondary-index">
      Add Secondary Indexes to Time Series Collections
     </a>
    </p>
   </div>
  </div>
 </section>
</section>
