Regarding your approach in 1., I would perhaps avoid this scenario as this is an implementation detail and it might change in future MongoDB versions as the feature is improved.
To get a better idea of what you’re trying to achieve with the second approach, would you be able to provide the following information:
- MongoDB Version in use.
- Sample document(s).
- Expected output.
- “Yet, I don’t know how to dynamically increase the window in the aggregation.” - Clarification on this and if you mean increasing the lower / upper bound of the time range in which documents are searched for within. Would you be able to provide an example on this scenario as well?
- “so duplicates must always be filtered out” - How are possible duplicates created and do you see this often enough that it affects your results?
Regards,
Jason