# Custom Query

**URL:** <https://discuss.elastic.co/t/custom-query/43785>\
**Category:** Kibana\
**Created:** [March 8, 2016, 2:17pm UTC](https://discuss.elastic.co/t/custom-query/43785 "2016-03-08T14:17:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjperes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjperes/32/8351_2.png) [@rjperes](https://discuss.elastic.co/u/rjperes)\
**Post date:** [March 8, 2016, 2:17pm UTC](https://discuss.elastic.co/t/custom-query/43785/1 "2016-03-08T14:17:32Z")

</div>

Hi,  
Is it possible to use a custom Elasticsearch query in Kibana? For example, I have a query that does several aggregations across different types, and I would like to setup a visualization for it. The Kibana UI only allows - AFAIK - relatively simple queries. This would be with the latest versions of ES (2.2.0) and Kibana (4.1.1).

Thanks!

RP

---

<div class="post-metadata">

**Author:** ![Khalah\_Jones\_Golden](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/khalah_jones_golden/32/7169_2.png) [@Khalah\_Jones\_Golden](https://discuss.elastic.co/u/Khalah_Jones_Golden)\
**Post date:** [March 8, 2016, 2:24pm UTC](https://discuss.elastic.co/t/custom-query/43785/2 "2016-03-08T14:24:47Z")

</div>

Could you give more of an example of what you're trying to do? It is correct however that kibana doesn't support some of ES' functions.

---

<div class="post-metadata">

**Author:** ![rjperes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjperes/32/8351_2.png) [@rjperes](https://discuss.elastic.co/u/rjperes)\
**Post date:** [March 8, 2016, 2:38pm UTC](https://discuss.elastic.co/t/custom-query/43785/3 "2016-03-08T14:38:50Z")

</div>

Thanks for the quick reply!  
Well, I want to do an aggregation over two types, say, A and B. Both are "correlated" by a common property, say, "correlationId". Then, type A has one property and type B has another. I would like to count those documents who have one property and those who haven't:

GET metrics/a,b/\_search  
{  
"aggs": {  
"all": {  
"terms": {  
"field": "correlationId"  
},  
"aggs": {  
"with\_disposition": {  
"terms": {  
"field": "disposition.dispText"  
}  
},  
"without\_disposition": {  
"missing": {  
"field": "disposition.dispText"  
}  
}  
}  
}  
}  
}

Is this clear for you? I have a couple of problems: I don't know Kibana enough and I am having a hard time living without JOINs! 🙂

Thanks,

RP

---

<div class="post-metadata">

**Author:** ![rjperes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjperes/32/8351_2.png) [@rjperes](https://discuss.elastic.co/u/rjperes)\
**Post date:** [March 8, 2016, 2:41pm UTC](https://discuss.elastic.co/t/custom-query/43785/4 "2016-03-08T14:41:45Z")

</div>

I forgot to say: I am only interested in the aggregations, not the actual query!

RP

---

<div class="post-metadata">

**Author:** ![ThomasVestergaard](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasvestergaard/32/16373_2.png) [@ThomasVestergaard](https://discuss.elastic.co/u/ThomasVestergaard)\
**Post date:** [March 15, 2017, 1:53pm UTC](https://discuss.elastic.co/t/custom-query/43785/5 "2017-03-15T13:53:50Z")

</div>

Any solution for this? I have the exact same challenge.

---

<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:32pm UTC](https://discuss.elastic.co/t/custom-query/43785/6 "2017-07-06T13:32:42Z")

</div>


