I think the"easiest" (not necessarily the most efficient) is save the data in 2 indices let's call them latest
and detail
.
In the latest
index you would use your serial number as the document _id
, and each time a document is ingested it will overwrite the entry. This assumes your serial number is unique across the entire data set. This index only the last update will appear.
In the detail
index you would not use your serial number as a document ID so every version of the document would be saved and then you could filter and look at and see the history
This is just one suggestion And there are some downsides to this as you have a bit more data and the latest index will have deleted documents which will be cleaned up at some point. (This can usually be automated) But on the other hand it's pretty straightforward and I've seen a number of users use this very successfully.
There Perhaps another approach with transforms but I'll let someone else answer that.
And yet again there may be another approach using aggregations and max time but it depends on How you want to display and look at the data.