# Bucket Script Syntax to Sum at Point in Time

**URL:** https://discuss.elastic.co/t/bucket-script-syntax-to-sum-at-point-in-time/168098
**Category:** Elasticsearch
**Created:** [February 12, 2019, 6:45pm UTC](https://discuss.elastic.co/t/bucket-script-syntax-to-sum-at-point-in-time/168098 "2019-02-12T18:45:47Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![sbvader](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sbvader/32/36795_2.png) [@sbvader](https://discuss.elastic.co/u/sbvader)
#### Post date: [February 12, 2019, 6:45pm UTC](https://discuss.elastic.co/t/bucket-script-syntax-to-sum-at-point-in-time/168098/1 "2019-02-12T18:45:47Z")

</div>

Hi, I have a single index and I am interested in the value fields when the 'host' is either A or B. It's easy to search for `host: A OR host: B` to get the list of documents that I am interested in, but then I basically want to make a new dataset where each timestamp corresponds to the sum of the values host A and B at that time. However, the timestamps don't match exactly - they can be different by magnitude of ~1 sec or less. Essentially, it's a similar operation to what 'stacking' the plots would do (if you view the top stacked line as the sum). I cannot change the way they're stored in Elastic (i.e., summing prior to their ingestion).

---

<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: [March 12, 2019, 6:45pm UTC](https://discuss.elastic.co/t/bucket-script-syntax-to-sum-at-point-in-time/168098/2 "2019-03-12T18:45:49Z")

</div>

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