MongoDB.local SF, Jan 15: See the speaker lineup & ship your AI vision faster. Use WEB50 to save 50%
Find out more >
Docs Menu
Docs Home
/ /

Migrate Data into a Time Series Collection with Aggregation

Starting in MongoDB version 7.0, you can use the $out aggregation stage to migrate data from an existing collection into a time series collection.

Note

MongoDB does not guarantee output order when you use $out to migrate data into a times series collection. To maintain order, sort your data before you migrate with an aggregation pipeline.

Consider a weather_data collection that contains time and metadata information:

For more information on additional considerations for migrating your data, see Best Practices for Time Series Collections.

If your original collection had secondary indexes, manually recreate them now.

If your time series collection includes timeField values before 1970-01-01T00:00:00.000Z or after 2038-01-19T03:14:07.000Z, MongoDB logs a warning and disables some query optimizations that make use of the internal clustered index. To regain query performance and resolve the log warning, create a secondary index on the timeField.

Tip

Back

Migrate Data

On this page