# Aggregation quires in Query DSL of add filters in Discover

**URL:** https://discuss.elastic.co/t/aggregation-quires-in-query-dsl-of-add-filters-in-discover/217923
**Category:** Kibana
**Created:** [February 5, 2020, 7:42am UTC](https://discuss.elastic.co/t/aggregation-quires-in-query-dsl-of-add-filters-in-discover/217923 "2020-02-05T07:42:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Satish512](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@Satish512](https://discuss.elastic.co/u/Satish512)
#### Post date: [February 5, 2020, 7:42am UTC](https://discuss.elastic.co/t/aggregation-quires-in-query-dsl-of-add-filters-in-discover/217923/1 "2020-02-05T07:42:29Z")

</div>

Hi team,

I'm trying to write a query in Query DSL of Add filters in Discover tab.  
"size": 0,  
"aggs": {  
"test": {  
"nested": {  
"path": "users"  
},  
"aggs": {  
"users": {  
"terms": {  
"field": "users.username.keyword"  
}  
}  
}  
}  
}

Issue : I'm getting result in Dev tools but if I execute same in Query DSL i'm getting this error " Discover: Internal Server Error ".

Could you please help on this.

Thanks,  
Satish.

---

<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: [February 5, 2020, 7:55am UTC](https://discuss.elastic.co/t/aggregation-quires-in-query-dsl-of-add-filters-in-discover/217923/2 "2020-02-05T07:55:40Z")

</div>

Welcome!

Anything in elasticsearch logs?

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

This is the icon to use if you are not using markdown format:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e6e239431ec2d71cbf1beef741f2e93e7cc762c.jpg)

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.  
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.

---

<div class="post-metadata">

### Author: ![Satish512](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@Satish512](https://discuss.elastic.co/u/Satish512)
#### Post date: [February 5, 2020, 11:52am UTC](https://discuss.elastic.co/t/aggregation-quires-in-query-dsl-of-add-filters-in-discover/217923/3 "2020-02-05T11:52:23Z")

</div>

Thanks!

I'm trying to write a query in Query DSL of Add filters in Discover tab.  
"size": 0,  
"aggs": {  
"consumer\_orgs": {  
"terms": {  
"field": "subscribers.consumerorgname.keyword"  
}}}  
Issue : I'm getting result in Dev tools but if I execute same in Query DSL i'm getting this error " Discover: Internal Server Error ".

Can we write aggregation queries in Query DSL in Discover?

---

<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: [February 5, 2020, 12:46pm UTC](https://discuss.elastic.co/t/aggregation-quires-in-query-dsl-of-add-filters-in-discover/217923/4 "2020-02-05T12:46:01Z")

</div>

Probably not but I moved your question to #kibana.

Again please [read this](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) about how to format.

---

<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: [March 4, 2020, 12:57pm UTC](https://discuss.elastic.co/t/aggregation-quires-in-query-dsl-of-add-filters-in-discover/217923/5 "2020-03-04T12:57:52Z")

</div>

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