# Add stop timestamp base on previous doc (event)

**URL:** <https://discuss.elastic.co/t/add-stop-timestamp-base-on-previous-doc-event/156320>\
**Category:** Elasticsearch\
**Created:** [November 12, 2018, 4:22pm UTC](https://discuss.elastic.co/t/add-stop-timestamp-base-on-previous-doc-event/156320 "2018-11-12T16:22:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![moimart1](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@moimart1](https://discuss.elastic.co/u/moimart1)\
**Post date:** [November 12, 2018, 4:22pm UTC](https://discuss.elastic.co/t/add-stop-timestamp-base-on-previous-doc-event/156320/1 "2018-11-12T16:22:40Z")

</div>

Hello,

I push some events to elasticsearch with the following structure:

```
{
    "name": "status",
    "value": "active",
    "timestamp": "2018-01-01T00:00:00.000Z"
}

```

And when I receive a new event with the same `name`, like

```
{
    "name": "status",
    "value": "stopped",
    "timestamp": "2018-01-01T01:00:00.000Z"
}

```

I want to update the event `status:active` with a `stopTimestamp` field, like

```
{
    "name": "status",
    "value": "active",
    "timestamp": "2018-01-01T00:00:00.000Z"
    "stopTimestamp": "2018-01-01T01:00:00.000Z"
}

```

The final goal is to show events / transactions on a timeline, and the timeline require the field `stop date`

It is possible to have a document with a start and a stop date base on two previous events ?

Thanks

Martin

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [November 12, 2018, 4:26pm UTC](https://discuss.elastic.co/t/add-stop-timestamp-base-on-previous-doc-event/156320/2 "2018-11-12T16:26:13Z")

</div>

> [@moimart1](#):
>
> And when I receive a new event with the same `name` , like

If you have lots of unique names to track see discussion on [Distinct count with filter](https://discuss.elastic.co/t/distinct-count-with-filter/155795)

---

<div class="post-metadata">

**Author:** ![moimart1](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@moimart1](https://discuss.elastic.co/u/moimart1)\
**Post date:** [November 14, 2018, 3:59pm UTC](https://discuss.elastic.co/t/add-stop-timestamp-base-on-previous-doc-event/156320/3 "2018-11-14T15:59:48Z")

</div>

Thanks

If I understand correctly, you suggest to do another index with my events with start stop from my events with only start.

How I can update automatically my new index ? I need to do an external script or I can have a "built-in" solution ?

---

<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:** [December 12, 2018, 3:59pm UTC](https://discuss.elastic.co/t/add-stop-timestamp-base-on-previous-doc-event/156320/4 "2018-12-12T15:59:56Z")

</div>

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