# How can I filter by count? / How can I apply a custom filter?

**URL:** <https://discuss.elastic.co/t/how-can-i-filter-by-count-how-can-i-apply-a-custom-filter/62722>\
**Category:** Kibana\
**Created:** [October 11, 2016, 2:31pm UTC](https://discuss.elastic.co/t/how-can-i-filter-by-count-how-can-i-apply-a-custom-filter/62722 "2016-10-11T14:31:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yeikel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yeikel/32/125434_2.png) [@yeikel](https://discuss.elastic.co/u/yeikel)\
**Post date:** [October 11, 2016, 2:31pm UTC](https://discuss.elastic.co/t/how-can-i-filter-by-count-how-can-i-apply-a-custom-filter/62722/1 "2016-10-11T14:31:13Z")

</div>

This question is a continuation of the following question : [https://discuss.elastic.co/t/filter-based-on-the-doc-count-with-aggregations/62677](https://discuss.elastic.co/t/filter-based-on-the-doc-count-with-aggregations/62677)

When building aggregations in Kibana , I get the following output :

 ![](https://us1.discourse-cdn.com/elastic/original/2X/0/0b23fb8adf6b591afe39ae1cc9963434ae174b32.png)

My question is , how can I **filter by count**?

For example : Build a visualization where `"doc_count": 4`

Or , how can I run this specific query ?

```
GET /cars/transactions/_search
{

   "size": 0,
   "aggs": {
      "popular_colors": {
         "terms": {
            "field": "color"
         },
         "aggs": {
            "my_filter": {
               "bucket_selector": {
                  "buckets_path": {
                     "the_doc_count": "_count"
                  },
                  "script": "the_doc_count == 4"
               }
            }
         }
      }
   }
}
```

---

<div class="post-metadata">

**Author:** ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)\
**Post date:** [October 11, 2016, 8:30pm UTC](https://discuss.elastic.co/t/how-can-i-filter-by-count-how-can-i-apply-a-custom-filter/62722/2 "2016-10-11T20:30:12Z")

</div>

That query at the end of your post uses a pipeline aggregation, which isn't yet supported in Kibana.

---

<div class="post-metadata">

**Author:** ![yeikel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yeikel/32/125434_2.png) [@yeikel](https://discuss.elastic.co/u/yeikel)\
**Post date:** [October 12, 2016, 2:23am UTC](https://discuss.elastic.co/t/how-can-i-filter-by-count-how-can-i-apply-a-custom-filter/62722/3 "2016-10-12T02:23:47Z")

</div>

Can you filter the doc\_count in Kibana with any other method?

---

<div class="post-metadata">

**Author:** ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)\
**Post date:** [October 13, 2016, 11:11pm UTC](https://discuss.elastic.co/t/how-can-i-filter-by-count-how-can-i-apply-a-custom-filter/62722/4 "2016-10-13T23:11:36Z")

</div>

not at the moment

---

<div class="post-metadata">

**Author:** ![yeikel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yeikel/32/125434_2.png) [@yeikel](https://discuss.elastic.co/u/yeikel)\
**Post date:** [October 15, 2016, 10:39pm UTC](https://discuss.elastic.co/t/how-can-i-filter-by-count-how-can-i-apply-a-custom-filter/62722/5 "2016-10-15T22:39:51Z")

</div>

I understand , thank you

---

<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, 1:36pm UTC](https://discuss.elastic.co/t/how-can-i-filter-by-count-how-can-i-apply-a-custom-filter/62722/6 "2017-07-06T13:36:28Z")

</div>


