Label data line as first or last

Hi, i am new to kibana, i have some data loaded into index pattern as below. new data will be uploaded every 30 min. i am having problem to label/determine the first and last data for each serial number. i think it is achieveable using scripted field but i am unable to find the correct script for this situation.

this is sample of the data loaded. i want to add two column/label for each line whether it is "is First" or "is Last" test.
Kibana1

this is for when new data is loaded, the "is Last" label changed depends on the date.
Kibana2

Thank you :slight_smile:

Welcome to our community! :smiley:

So are the first and last states based only on the timings in the batch of data when it is loaded in? The batches are not related in anyway?

Hi warkolm, thank you for prompt respond. i am looking to based on those two parameter only. the Serial and the LastTestDate column. but if there is new data for that particular Serial, then the "is Last" data will change accordingly

That changes your approach a fair bit, as you need to read the data in Elasticsearch and then update it accordingly. You might want to look at using Logstash or an ingest pipeline to handle this.

meaning i cant use Scripted field for this issue?

I am not sure it could handle that level of complexity.

Thanks man. lets wait if got other opinion on this. :slight_smile: