# Querying Nested Type content

**URL:** https://discuss.elastic.co/t/querying-nested-type-content/42905
**Category:** Elasticsearch
**Created:** [February 27, 2016, 2:22am UTC](https://discuss.elastic.co/t/querying-nested-type-content/42905 "2016-02-27T02:22:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Karthik\_Ramachandran](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@Karthik\_Ramachandran](https://discuss.elastic.co/u/Karthik_Ramachandran)
#### Post date: [February 27, 2016, 2:22am UTC](https://discuss.elastic.co/t/querying-nested-type-content/42905/1 "2016-02-27T02:22:44Z")

</div>

I'm trying to see if the below are possible using Elastic search querying. I'm finding it hard, but looks like these are not possible.

My content structure looks someething like below. It is a document with multiple nested type values.

{  
Attr1: YYYY-mm-dd  
Attr2: Single Term Value  
Attr3: Array of strings  
Attr4: Number Value  
Attr5: String (analyzed - it is the only analyzed item)  
List1:{ type:nested,  
properties:{List1Attr1:string,List1Attr2:Number Value, List1Attr3:True/False}  
}  
List2:{ type:nested,  
properties:{List2Attr1:string,List2Attr2:Number Value, List2Attr3:True/False}  
}  
}

I need output like

List1.List1Attr, List2.List2Attr1, count(documents),AVG(List1Attr2)

In SQL terms, it is something like

SELECT List1.List1Attr, List2.List2Attr1, COUNT(Master.Key),AVG(List1.List1Attr2)  
FROM Master  
JOIN List1 \<\>  
JOIN List2 \<\>  
GROUP BY List1.List1Attr, List2.List2Attr1

Note: I need to have the above two lists as nested type or I can make parent child, but it is business need.

I'm also trying with another mapping type where I'm eliminating to have two nested type instead have one. But no success so far. In this case the mapping would

CombinedList:{type:nested  
,properties:{ListType:string,ListAttr1:string,ListAttr2:number,listAttr3:true/false}}

Any help is appreciated.

---

<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, 11:13pm UTC](https://discuss.elastic.co/t/querying-nested-type-content/42905/2 "2017-07-05T23:13:09Z")

</div>


