# Multiple documents same id find difference

**URL:** https://discuss.elastic.co/t/multiple-documents-same-id-find-difference/124025
**Category:** Elasticsearch
**Created:** [March 15, 2018, 4:35am UTC](https://discuss.elastic.co/t/multiple-documents-same-id-find-difference/124025 "2018-03-15T04:35:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sureshboiina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sureshboiina/32/79183_2.png) [@sureshboiina](https://discuss.elastic.co/u/sureshboiina)
#### Post date: [March 15, 2018, 4:35am UTC](https://discuss.elastic.co/t/multiple-documents-same-id-find-difference/124025/1 "2018-03-15T04:35:42Z")

</div>

HI,

Actually have sample data like

```
id,date,value
1,12-03-2018:12:12:234,3
1,12-03-2018:12:13:234,4
2,12-03-2018:12:18:264,2
2,12-03-2018:12:20:234,9

```

**Want to have date difference and value difference between the docs is it possible?**

```
output:
1,1,1
2,2,7
```

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [March 15, 2018, 4:50am UTC](https://discuss.elastic.co/t/multiple-documents-same-id-find-difference/124025/2 "2018-03-15T04:50:53Z")

</div>

I don't think so.

You should better solve that problem at index time IMO. Like getting the old document if any then updating it (use the document id).

If the document existed, then compute a duration.

But all that needs to happen on the application side.

If you are using logstash there is a nice plugin for that: aggregate

---

<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: [April 12, 2018, 4:51am UTC](https://discuss.elastic.co/t/multiple-documents-same-id-find-difference/124025/3 "2018-04-12T04:51:06Z")

</div>

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