(Location40415) BSON field 'create.timeseries' is an unknown field

Hi. I am trying to create a timeseries collection using golang. My code looks like this:

tso := options.TimeSeries()
tso.SetTimeField("time")
tso.SetMetaField("meta")
tso.SetGranularity("minutes")

cco := options.CreateCollection()
cco.SetTimeSeriesOptions(tso)

err := db.CreateCollection(context.Background(), "data", cco)
if err != nil {
	log.Panic(err)
}

I always get the error

panic: (Location40415) BSON field 'create.timeseries' is an unknown field.

The only related post I found was on stack. However, it was not helpful, since I don’t use any validation.

Can someone tell me how to fix it? Or link me some code, where someone has done this before?

Hello @bhterwhre_hbrteqher!

Timeseries collections are a new feature in the MongoDB 5.0 server version. That error message is returned when attempting to create a collection with the timeseries option on older server versions. Can you confirm which version of the server you are running against?

Sincerely,
Kevin

2 Likes

Awesome! Updating to 5.0 worked. Thanks @Kevin_Albertson :smiley:

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.