# How to compute for the fields of matching documents in Elasticsearch?

**URL:** <https://discuss.elastic.co/t/how-to-compute-for-the-fields-of-matching-documents-in-elasticsearch/20601>\
**Category:** Elasticsearch\
**Created:** [November 6, 2014, 10:57am UTC](https://discuss.elastic.co/t/how-to-compute-for-the-fields-of-matching-documents-in-elasticsearch/20601 "2014-11-06T10:57:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Relaxx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/relaxx/32/1120_2.png) [@Relaxx](https://discuss.elastic.co/u/Relaxx)\
**Post date:** [November 6, 2014, 10:57am UTC](https://discuss.elastic.co/t/how-to-compute-for-the-fields-of-matching-documents-in-elasticsearch/20601/1 "2014-11-06T10:57:01Z")

</div>

Here is my sample document:

{  
"jobID": "ace4c888-1907-4021-a808-4a816e99aa2e",  
"startTime": 1415255164835,  
"endTime": 1415255164898,  
"moduleCode": "STARTING\_MODULE"  
}

- I have thousands of documents.
- I have a pair of documents with the _same jobID_ and the module code  
would be STARTING\_MODULE and ENDING\_MODULE.
- My formula would be ENDING\_MODULE endTime minus STARTING\_MODULE  
startTime equals the elapsed time it took the module to process.

My question is: _How do I get the total of all results with the elapsed  
time that is less than let's say 28800000?_

Is such results possible with Elasticsearch? I'd like to display my results  
in Kibana too.

Please let me know if this needs more clarification. Thanks!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/ca558162-d0f3-4857-860c-a0d36e43eee9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ca558162-d0f3-4857-860c-a0d36e43eee9%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 12:51am UTC](https://discuss.elastic.co/t/how-to-compute-for-the-fields-of-matching-documents-in-elasticsearch/20601/2 "2017-07-06T00:51:52Z")

</div>


