# What I am wrong with this query?

**URL:** <https://discuss.elastic.co/t/what-i-am-wrong-with-this-query/141681>\
**Category:** Elasticsearch\
**Created:** [July 26, 2018, 2:41am UTC](https://discuss.elastic.co/t/what-i-am-wrong-with-this-query/141681 "2018-07-26T02:41:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Moon](https://avatars.discourse-cdn.com/v4/letter/m/f07891/32.png) [@Moon](https://discuss.elastic.co/u/Moon)\
**Post date:** [July 26, 2018, 2:41am UTC](https://discuss.elastic.co/t/what-i-am-wrong-with-this-query/141681/1 "2018-07-26T02:41:46Z")

</div>

I want to filter data =\> DataType : T  
bucket =\> Term : PLANT\_CD

I wrote

"query" : {  
"bool":{  
"must" : [{  
"match" : {  
"DataType" : "T"  
}  
}]  
},  
"aggs": {  
"plants": {  
'terms': {"field": "PLANT\_CD"}  
}  
}  
}

But it does not work. what is the problem?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 26, 2018, 4:04am UTC](https://discuss.elastic.co/t/what-i-am-wrong-with-this-query/141681/2 "2018-07-26T04:04:01Z")

</div>

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<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:** [August 23, 2018, 4:04am UTC](https://discuss.elastic.co/t/what-i-am-wrong-with-this-query/141681/3 "2018-08-23T04:04:05Z")

</div>

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