# Problem with custom filter sub aggregations in area visualization

**URL:** <https://discuss.elastic.co/t/problem-with-custom-filter-sub-aggregations-in-area-visualization/188376>\
**Category:** Kibana\
**Created:** [July 1, 2019, 5:13pm UTC](https://discuss.elastic.co/t/problem-with-custom-filter-sub-aggregations-in-area-visualization/188376 "2019-07-01T17:13:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![letailli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/letailli/32/46119_2.png) [@letailli](https://discuss.elastic.co/u/letailli)\
**Post date:** [July 1, 2019, 5:13pm UTC](https://discuss.elastic.co/t/problem-with-custom-filter-sub-aggregations-in-area-visualization/188376/1 "2019-07-01T17:13:58Z")

</div>

I try to represent trough time documents containing reference to some countries and not containing them.

I set 2 filters

```
GET /article/_search
{
  "size": 0,
  "aggs" : {
    "country" : {
      "filter":{
          "bool":{
              "must": {
                    "terms":{
                    "Fulltext" : ["sierra leone", "liberia"]
                    }
                  }
          }
      }
    },
    "not_country" : {
      "filter":{
          "bool":{
              "must_not": {
                    "terms":{
                    "Fulltext" : ["sierra leone", "liberia"]
                    }
                  }
          }
      }
    }
  }
} 

```

And it seems fine. I get this return

```
{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 5285,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : []
  },
  "aggregations" : {
    "country" : {
      "doc_count" : 713
    },
    "not_country" : {
      "doc_count" : 4572
    }
  }
} 

```

But the problem comes when I use those filters in the area vizualisation settings (Buckets \> Split Series \> Sub Aggregation \> Filters). The vizualisation shows 0 "not\_country" documents whereas there should be 713. And even the "country" documents count is wrong (I got 2432 when I gather them all in a custom time period whereas I should get 4572).

 ![kibana_graph](https://us1.discourse-cdn.com/elastic/original/3X/5/9/5932b35e02eea41e426a8b29143c2d025fba9a0b.png)

Can you help me ?

---

<div class="post-metadata">

**Author:** ![Larry\_Gregory](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/larry_gregory/32/34969_2.png) [@Larry\_Gregory](https://discuss.elastic.co/u/Larry_Gregory)\
**Post date:** [July 1, 2019, 7:00pm UTC](https://discuss.elastic.co/t/problem-with-custom-filter-sub-aggregations-in-area-visualization/188376/2 "2019-07-01T19:00:40Z")

</div>

Hey @letailli, welcome to the discussion boards!

It's not clear to me how you're setting the `country` and `not_country` filters in your screenshot above. I would have expected to see something like my screenshot below, with the two filters specified inline:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/f/efe575677499be589c4c845b8e6021a49ebcf3d1.png)

---

<div class="post-metadata">

**Author:** ![letailli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/letailli/32/46119_2.png) [@letailli](https://discuss.elastic.co/u/letailli)\
**Post date:** [July 2, 2019, 8:44am UTC](https://discuss.elastic.co/t/problem-with-custom-filter-sub-aggregations-in-area-visualization/188376/3 "2019-07-02T08:44:01Z")

</div>

It works perfectly that way !  
Thank you very much

---

<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 30, 2019, 8:44am UTC](https://discuss.elastic.co/t/problem-with-custom-filter-sub-aggregations-in-area-visualization/188376/4 "2019-07-30T08:44:07Z")

</div>

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