# Elastic Search - Difference betweeen timestamp of 2 child documents

**URL:** <https://discuss.elastic.co/t/elastic-search-difference-betweeen-timestamp-of-2-child-documents/122945>\
**Category:** Elasticsearch\
**Created:** [March 7, 2018, 6:52pm UTC](https://discuss.elastic.co/t/elastic-search-difference-betweeen-timestamp-of-2-child-documents/122945 "2018-03-07T18:52:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Diego\_Agriel](https://avatars.discourse-cdn.com/v4/letter/d/c57346/32.png) [@Diego\_Agriel](https://discuss.elastic.co/u/Diego_Agriel)\
**Post date:** [March 7, 2018, 6:52pm UTC](https://discuss.elastic.co/t/elastic-search-difference-betweeen-timestamp-of-2-child-documents/122945/1 "2018-03-07T18:52:33Z")

</div>

I have a parent-child relationship betweeen documents as described in the official documentation ([https://www.elastic.co/guide/en/elasticsearch/guide/2.x/parent-child.html](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/parent-child.html)).

The child documents has a field "timestamp". I need to compute/query the difference between 2 different child's timestamp.

Example:

```
                     parent document
                      | |
                      | |
          child document 1 child document 2
          * timestamp1 * timestamp2

```

The value I want is: timestamp2 - timestamp1

Changing the child documents to nested objects in the parent is not an option.

For what a read, using scripts is not possible as child's field cannot be accessed from the parent document.

I'm using the Java API.

Any ideas?

---

<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 4, 2018, 6:56pm UTC](https://discuss.elastic.co/t/elastic-search-difference-betweeen-timestamp-of-2-child-documents/122945/2 "2018-04-04T18:56:57Z")

</div>

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