# Aggregate events over a large period of time maintaining previous task maps

**URL:** <https://discuss.elastic.co/t/aggregate-events-over-a-large-period-of-time-maintaining-previous-task-maps/251178>\
**Category:** Logstash\
**Created:** [October 6, 2020, 6:54pm UTC](https://discuss.elastic.co/t/aggregate-events-over-a-large-period-of-time-maintaining-previous-task-maps/251178 "2020-10-06T18:54:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arichiardi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arichiardi/32/76109_2.png) [@arichiardi](https://discuss.elastic.co/u/arichiardi)\
**Post date:** [October 6, 2020, 6:54pm UTC](https://discuss.elastic.co/t/aggregate-events-over-a-large-period-of-time-maintaining-previous-task-maps/251178/1 "2020-10-06T18:54:00Z")

</div>

Hi all, I am new to logstash and aggregate - but not too event sourcing/CQRS and I am looking for a strategy to handle the following problem.

I have a `product.created` that contains the initial available products.  
I then have consecutive `stock.updated` that contain increments/decrements of the quantity.

I am using the aggregate plugin but I am struggling to see how this would work in case the `product created` product comes way before the updates.

From what I see every time aggregate times out it evicts the map and this is a problem for me cause when I receive an update I am always going to need the previous result (kind of like doing a reduce over the events).

I was wondering if there is a way _not_ to evict the map? Am I doing it right?

Thank you in advance for all your answers.

---

<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:** [November 3, 2020, 6:54pm UTC](https://discuss.elastic.co/t/aggregate-events-over-a-large-period-of-time-maintaining-previous-task-maps/251178/2 "2020-11-03T18:54:01Z")

</div>

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