# How to filter the aggregated data

**URL:** <https://discuss.elastic.co/t/how-to-filter-the-aggregated-data/173167>\
**Category:** Elasticsearch\
**Created:** [March 20, 2019, 2:12pm UTC](https://discuss.elastic.co/t/how-to-filter-the-aggregated-data/173167 "2019-03-20T14:12:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![brian123](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brian123/32/42422_2.png) [@brian123](https://discuss.elastic.co/u/brian123)\
**Post date:** [March 20, 2019, 2:12pm UTC](https://discuss.elastic.co/t/how-to-filter-the-aggregated-data/173167/1 "2019-03-20T14:12:40Z")

</div>

I use bucket\_script in my search, and I got a new field called "useagerss" by bucket\_script. Now, i holp to filter the data.When the "useagerss" is greater than 0.85,print it to the result,conversely, not print to the result. but I don't know how to implement it.

my configuration:

```auto
                    "useagerss": {
                      "bucket_script": {
                        "buckets_path": {
                          "available": "3",
                          "usage": "4",
                          "rss": "5"
                        },
                        "script": {
                          "source": "params.rss / ( params.available + params.usage) > 0.85 ? (params.rss / ( params.available + params.usage)):0",
                          "lang": "painless"
                        },
                        "format": "#.##"
                      }
                    }

```

The above method just lets it print to 0 when the value is less than 0.85, but it does not discard it.

How should I solve it? Can you give me an example？

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [March 20, 2019, 4:47pm UTC](https://discuss.elastic.co/t/how-to-filter-the-aggregated-data/173167/2 "2019-03-20T16:47:35Z")

</div>

The [bucket selector aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-selector-aggregation.html) allows you to do exactly that.

---

<div class="post-metadata">

**Author:** ![brian123](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brian123/32/42422_2.png) [@brian123](https://discuss.elastic.co/u/brian123)\
**Post date:** [March 21, 2019, 3:14am UTC](https://discuss.elastic.co/t/how-to-filter-the-aggregated-data/173167/3 "2019-03-21T03:14:16Z")

</div>

Thank you very much! abdon.This problem has been solved.

---

<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 18, 2019, 3:14am UTC](https://discuss.elastic.co/t/how-to-filter-the-aggregated-data/173167/4 "2019-04-18T03:14:18Z")

</div>

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