Range output from Elastic query search

I have to query Elastic search to return time ranges
My data is
{"run-id": "xxx", "name": "unknown", "event" : [{"value": "event name1"}], "epoch" : 1576530536}
{"run-id": "xxx", "name": "unknown", "event" : [{"value": "event name1"}], "epoch" : 1576530537}
{"run-id": "xxx", "name": "unknown", "event" : [{"value": "event name1"}], "epoch" : 1576530540}
{"run-id": "xxx", "name": "unknown", "event" : [{"value": "event name1"}], "epoch" : 1576530541}
{"run-id": "xxx", "name": "unknown", "event" : [{"value": "event name1"}], "epoch" : 1576530542}

I need output as 1576530536-1576530537 and 1576530540-1576530542 when searched for event=event name1. Is there a way to return values as range with start and end epoch

it depends on how you want to model your data. The range datatype could help you in that case.

I am open to suggestions for changing data model, but I understand range is an input to search query, what I need is output to be range values.

hm, I am still not sure about the requirement to be honest. If you want to group things together, maybe a histogram aggregation could help you in order to group data together.

maybe you can explain in more detail what your grouping criteria is. A distance greater than one?

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