# Count document in absolute time interval

**URL:** <https://discuss.elastic.co/t/count-document-in-absolute-time-interval/111858>\
**Category:** Elasticsearch\
**Created:** [December 14, 2017, 8:36pm UTC](https://discuss.elastic.co/t/count-document-in-absolute-time-interval/111858 "2017-12-14T20:36:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detobel36](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/detobel36/32/25607_2.png) [@Detobel36](https://discuss.elastic.co/u/Detobel36)\
**Post date:** [December 14, 2017, 8:36pm UTC](https://discuss.elastic.co/t/count-document-in-absolute-time-interval/111858/1 "2017-12-14T20:36:56Z")

</div>

Hi,

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:

 ![capt](https://us1.discourse-cdn.com/elastic/original/3X/d/5/d5d520f19e7e889a5d04a959b3a7acdd13ee2184.png)

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:

```auto
 [
    {
        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,  
Detobel36

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 11, 2018, 8:41pm UTC](https://discuss.elastic.co/t/count-document-in-absolute-time-interval/111858/2 "2018-01-11T20:41:47Z")

</div>

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