aneroid
(Anirudh Dutt)
2
I’m going to assume you mean “inserts time series data into a Time Series collection” since the behaviour you describe is not possible in regular collections. Edit: If that did happen for regular collections, it would be a serious bug.
Not a bug and not any issue at your end. By default, Time Series collections don’t create a unique index on the _id field.
When you create a Time Series collection, a compound index will be created on the metaField and timeField. Note that even this is not a unique index.
Using the example from the docs, doing:
db.createCollection(
"stocks",
{
timeseries: {
timeField: "date",
metaField: "ticker",
granularity: "seconds"
}
})
will create a time series collection with a compound index on ticker & date, which are the metaField and timeField above. Using db.getCollection("stocks").getIndexes(), gives:
[ { v: 2, key: { ticker: 1, date: 1 }, name: 'ticker_1_date_1' } ]
Again, note that it’s not a unique index and no index on _id is listed above.
Seen here:
However, I would agree that the documentation about this behaviour in Time Series collections could be improved and made clear.
1 Like