# Calculate timestamp duration to next document

**URL:** https://discuss.elastic.co/t/calculate-timestamp-duration-to-next-document/297244
**Category:** Logstash
**Created:** [February 15, 2022, 1:04pm UTC](https://discuss.elastic.co/t/calculate-timestamp-duration-to-next-document/297244 "2022-02-15T13:04:52Z")
**Posts on this page:** 1
**Showing post:** 13

<div class="post-metadata">

### Author: ![Hendrik\_Muhs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hendrik_muhs/32/25802_2.png) [@Hendrik\_Muhs](https://discuss.elastic.co/u/Hendrik_Muhs)
#### Post date: [February 17, 2022, 11:25am UTC](https://discuss.elastic.co/t/calculate-timestamp-duration-to-next-document/297244/13 "2022-02-17T11:25:39Z")

</div>

Your reducer returns an empty list as you are not concatenating anything:

```auto
def docs = []; return docs

```

In order to return something you need to collect the docs.

Think of it like this:

_map_ is executed on every shard for _every_ document. You add the doc to a list.  
_combine_ is executed _once_ per shard, you return the list. You end up with 1 list per shard.  
_reduce_ is executed _exactly once_ per search. You get the lists of every shard and you need to combine them into 1 output.

It seems you are a german speaker, therefore I suggest this detailed walk-through with example code and docs: [Dec 5th, 2019 [DE] Weihnachtswünsche zusammenfassen mit Transforms](https://discuss.elastic.co/t/dec-5th-2019-de-weihnachtswunsche-zusammenfassen-mit-transforms/209946)

---

_[View the full topic](https://discuss.elastic.co/t/calculate-timestamp-duration-to-next-document/297244)._
