# Max Bucket Aggregation: Only return that result?

**URL:** https://discuss.elastic.co/t/max-bucket-aggregation-only-return-that-result/158955
**Category:** Elasticsearch
**Created:** [November 30, 2018, 7:04pm UTC](https://discuss.elastic.co/t/max-bucket-aggregation-only-return-that-result/158955 "2018-11-30T19:04:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Speedman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/speedman/32/37066_2.png) [@Speedman](https://discuss.elastic.co/u/Speedman)
#### Post date: [November 30, 2018, 7:04pm UTC](https://discuss.elastic.co/t/max-bucket-aggregation-only-return-that-result/158955/1 "2018-11-30T19:04:32Z")

</div>

Here's the query I'm running:

```
{
    "size": 0,
    "query": {
        "range": {
            "timestamp": {
                "gte": "2018-11-28",
                "lte": "2018-11-28"
            }
        }
    },
    "aggs": {
        "hits_per_minute": {
            "date_histogram": {
                "field": "timestamp",
                "interval": "minute"
            },
            "aggs": {
                "total_hits": {
                    "sum": {
                        "field": "hits_count"
                    }
                }
            }
        },
        "max_transactions_per_minute": {
            "max_bucket": {
                "buckets_path": "hits_per_minute>total_hits"
            }
        }
    }
}

```

(If anybody needs to know, the docs in question contain fields that show the total hits for our API endpoints over the course of a minute, with one doc per minute from each instance.)

The max bucket works just fine and gives me the results I want. Is there a way to skip the rest of the results, though? I don't need to actually see the total hits for each minute, just the maximum.

---

<div class="post-metadata">

### Author: ![Speedman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/speedman/32/37066_2.png) [@Speedman](https://discuss.elastic.co/u/Speedman)
#### Post date: [December 5, 2018, 9:29pm UTC](https://discuss.elastic.co/t/max-bucket-aggregation-only-return-that-result/158955/2 "2018-12-05T21:29:15Z")

</div>

Found the answer: [response filtering using the filter\_path option in the URL](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#common-options-response-filtering):

_[http://hostname/index/\_search](http://hostname/index/_search)_ **?filter\_path=aggregations.max\_transactions\_per\_minute**

---

<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: [January 2, 2019, 9:29pm UTC](https://discuss.elastic.co/t/max-bucket-aggregation-only-return-that-result/158955/3 "2019-01-02T21:29:23Z")

</div>

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