Count document in absolute time interval


I store some video information in ElasticSearch. And more particularly, the time (of the video) when a user begin to see the video and the time until he stop the video. Like in the next picture:

I would like to count how much user see the video on each second of this video. In the other world, i would like an output like this:

        time: 0,
        count: 100
    }, {
        time: 1,
        count: 70
    }, {
    }, {
        time: 360,
        count: 30

To make this we "just" must to see if "time" is between "start" and "start + view_time" and to have the total time we just must to make "max(start+view_time)".
I don't know if it's natively possible... Or if it exist something to have "view count" second per second.

Thanks to you,

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