# Nested elastic query

**URL:** <https://discuss.elastic.co/t/nested-elastic-query/72209>\
**Category:** Elasticsearch\
**Created:** [January 19, 2017, 6:53pm UTC](https://discuss.elastic.co/t/nested-elastic-query/72209 "2017-01-19T18:53:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sabyasachi\_mallick](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@sabyasachi\_mallick](https://discuss.elastic.co/u/sabyasachi_mallick)\
**Post date:** [January 19, 2017, 6:53pm UTC](https://discuss.elastic.co/t/nested-elastic-query/72209/1 "2017-01-19T18:53:00Z")

</div>

i am a bit new to elastic queries.  
i have a requirement like this..i have a field "X" which contains values like a,b,c,d,e.... . and another field "Y" which contains values like r,s,t,u,v (here i know values in Y and that too only 6 types) but in X i don't know how many types of values are there.  
i want to write a query which will return me the count of types of Y values for each type of X .  
e.g  
a: {r:10,s:4,t:6,u:14,v:45}  
b: {r:12,s:43,t:60,u:34,v:41}  
.......

any help ll be appreciated!!  
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:** [February 16, 2017, 6:53pm UTC](https://discuss.elastic.co/t/nested-elastic-query/72209/2 "2017-02-16T18:53:25Z")

</div>

Closed on February 16, 2017, 6:53pm UTC

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