Going direct with time series data in Compass to Atlas, and Compass to an on premise MongoDB to make sure the aggregation is correct:
db.umvtracking.aggregate([
{
$project: {
date: {
$dateToParts: { date: "$timestamp" }
},
temp: 1
}
},
{
$group: {
_id: {
umv: {
serialnumber: "$serial.number",
unitnumber: "$unit.number"
}
date: {
year: "$date.year",
month: "$date.month",
day: "$date.day",
time: "$time.time"
},
engagement: { $target: "$target",
targetdetection: {
estimatedsize: "$estimated.size",
speed: "$speed",
direction: "$direction",
location: "$location",
numberoftargets: "$numberoftargets"
}
}
}
}, {
$merge: { into: "identifiedtargets", whenMatched: "replace" }
}
])