# Elasticsearch1.7 need to filter from aggs key value

**URL:** <https://discuss.elastic.co/t/elasticsearch1-7-need-to-filter-from-aggs-key-value/54033>\
**Category:** Elasticsearch\
**Created:** [June 27, 2016, 12:01pm UTC](https://discuss.elastic.co/t/elasticsearch1-7-need-to-filter-from-aggs-key-value/54033 "2016-06-27T12:01:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dilip\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dilip_kumar/32/15459_2.png) [@Dilip\_Kumar](https://discuss.elastic.co/u/Dilip_Kumar)\
**Post date:** [June 27, 2016, 12:01pm UTC](https://discuss.elastic.co/t/elasticsearch1-7-need-to-filter-from-aggs-key-value/54033/1 "2016-06-27T12:01:26Z")

</div>

## Hi, `{"RU": "2016-06-25T15:07:46.144","zt":"bl","zi":"z101"} {"RU": "2016-06-25T15:07:46.144","zt":"bl","zi":"z102"} {"RU": "2016-06-25T15:07:46.144","zt":"bl","zi":"z103"} {"RU": "2016-06-25T15:07:46.144","zt":"un","zi":"z201"} {"RU": "2016-06-25T15:07:46.144","zt":"un","zi":"z202"} {"RU": "2016-06-25T15:07:46.144","zt":"g1","zi":"z101"} {"RU": "2016-06-25T15:07:46.144","zt":"g1","zi":"z502"} {"RU": "2016-06-25T15:07:46.144","zt":"g2","zi":"z201"} {"RU": "2016-06-25T15:07:46.144","zt":"g2","zi":"z503"} My query : {"size": 0, "aggs": { "findunique": { "filter": { "bool": { "must\_not": [{ "terms": { "zt": [ "bl", "un"] } } ], "must": [{ "terms": { "zt": [ "g1", "g2"] } } ] } }, "aggs": { "uniquezi": { "terms": { "field": "zi" } } } } } }

output :  
{"aggregations": {  
"findunique": {  
"doc\_count": 4,  
"uniquezi": {  
"doc\_count\_error\_upper\_bound": 0,  
"sum\_other\_doc\_count": 0,  
"buckets": [  
{  
"key": "z101",  
"doc\_count": 1  
},  
{  
"key": "z201",  
"doc\_count": 1  
},  
{  
"key": "z502",  
"doc\_count": 1  
},  
{  
"key": "z503",  
"doc\_count": 1  
}  
]  
}  
}  
}  
`  
Now i am looking to don't show zi =z101 and z201 should not come in bucket key even doc count is one or more as that belonging to zt = bl and zt = un  
Please suggest me Thanks !

---

<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 5, 2017, 10:40pm UTC](https://discuss.elastic.co/t/elasticsearch1-7-need-to-filter-from-aggs-key-value/54033/2 "2017-07-05T22:40:17Z")

</div>

Closed on July 5, 2017, 10:40pm UTC


