Combine two index in one using Kibana

Hello,

I have a requirement to combine two index in Elasticsearch on basis of below criteria -
index1:
Record1: {"service": "abc", "opened_at":"2024-11-04T16:48:04.000Z","closed_at":"2024-11-05T18:00:10.000Z")
Record2: {"service": "abc", "opened_at":"2024-11-06T16:48:04.000Z","closed_at":"2024-11-07T18:00:10.000Z")

index2:
Record1: {"service": "abc", "opened_at":"2024-11-06T16:48:04.000Z","closed_at":"2024-11-17T18:00:10.000Z")
Record2: {"service": "abc", "opened_at":"2024-11-10T16:48:04.000Z","closed_at":"2024-11-17T18:00:10.000Z")

So I want to correalet both of them on basis of service for example service and closed time on index 1 correlate to index2 service same and open time should be more than the closed time in index1 and less then the closed time of next record .
In that case index1 record1 will correlate to index2 record 1 .

Please suggest.

Hi @amity.nidhi Welcome to the Elastic community. Do you want to fetch all records which satisfying above conditions? or do you want to perform some calculation ? You can simply perform query on both the index index1,index2.

I want to fetch all records satisfying this condition and present it in dashboard

You can achieve this using script query. Could you help us with your index mapping and sample document index query. I will try to build query accordingly. thanks