Can I create a Data table which aggregates a top hit per ID?

Imagine that I have documents with the fields ID, ValueA, ValueB and that my index for each ID, let's say from 1 to 50 have some random values for A and B.

Is it possible to build a visualization with 50 rows, one per ID and aggregate for each row the latest value for each property (ValueA, ValueB), filtered by the ID key?

"Last Value" in Lens uses top_hits under the hood and likely could accomplish this. Here's an example where "host" is an example field and my "host.cpu.usage" is an example metric that i'm using last value / top_hits on

Hi Graham,

Thank you for the advice, I was able to solve it a while ago, not sure if my solution was the best but what I did was a scripted field for my ID (the id was text and I converted it to a number), the I added the Top values for the IDs and sorted it, then in the metrics I just added the properties I needed using the Last value and it worked fine.

Sorry for not updating the status of this question earlier but I sorted it out just a while ago.

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