# Elasticsearch Query discard documents where sum of field is x

**URL:** <https://discuss.elastic.co/t/elasticsearch-query-discard-documents-where-sum-of-field-is-x/288916>\
**Category:** Elasticsearch\
**Created:** [November 10, 2021, 5:23pm UTC](https://discuss.elastic.co/t/elasticsearch-query-discard-documents-where-sum-of-field-is-x/288916 "2021-11-10T17:23:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjammin92](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jjammin92](https://discuss.elastic.co/u/jjammin92)\
**Post date:** [November 10, 2021, 5:23pm UTC](https://discuss.elastic.co/t/elasticsearch-query-discard-documents-where-sum-of-field-is-x/288916/1 "2021-11-10T17:23:56Z")

</div>

Hello,

I have documents that look like the following:

```auto
  "_index": "test",
  "_type": "_doc",
  "_id": "p767Cn0BpA6tOYGm9B_P",
  "_version": 1,
  "_score": null,
  "_source": {
    "path": "entry_1",
    "elap_t": 89,
    "account_type": "b1",
    "order_key": "911cd7bf476e39dfcfc2b3c6b23860",
    "repeat": 0,
    "timestamp": 2021-11-10T16:42:46.000Z

```

I'm trying to build a query that only shows documents after the first documents where teh `elap_t` field totals `1800` Documents will have an `elap_t` field of arbitrary values. I think what I need to do is sort the documents in ascending order and somehow only show the documents after the first documents where the total of `elap_t > 1800` Does that make sense and is this even doable in Elasticsearch?

---

<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 8, 2021, 5:24pm UTC](https://discuss.elastic.co/t/elasticsearch-query-discard-documents-where-sum-of-field-is-x/288916/2 "2021-12-08T17:24:34Z")

</div>

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