I've got a dataset that looks like this:
{
"id": 1234,
"name": "name-1",
"timestamp: "2022-02-10T13:48:32.195344Z",
}
There are several thousand documents with unique id's in the database I'm trying to grab. However the issue is the "name"
property can change with each id, so there can be multiple documents that have the same id but different name.
For my result set I'm trying to return a full list of all the documents of each unique id-name pair, but only one document for each pair that is the document with the latest timestamp.
For example with four documents with the id of "1234" and "name-2", I'd only want to return one of those documents that has the latest timestamp.
There are millions of documents in this dataset, so performance is a concern here as well.
Is there any way to build this query with cts functions or similar?