# Nested types in queries

**URL:** <https://discuss.elastic.co/t/nested-types-in-queries/7601>\
**Category:** Elasticsearch\
**Created:** [May 8, 2012, 3:17pm UTC](https://discuss.elastic.co/t/nested-types-in-queries/7601 "2012-05-08T15:17:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dennis](https://avatars.discourse-cdn.com/v4/letter/d/e56c9b/32.png) [@Dennis](https://discuss.elastic.co/u/Dennis)\
**Post date:** [May 8, 2012, 3:17pm UTC](https://discuss.elastic.co/t/nested-types-in-queries/7601/1 "2012-05-08T15:17:19Z")

</div>

I read in a recent post on this forum that nested data cannot be sorted  
upon in the query results? Is this true? It'd be a good thing to put on the  
nested type page 🙂

It really kills any practical use for my project, alas.

Also, what exactly gets returned by default doing nested queries? All of  
the parent and all of the nested child that matched? Can any of that be  
controlled?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 10, 2012, 5:54am UTC](https://discuss.elastic.co/t/nested-types-in-queries/7601/2 "2012-05-10T05:54:32Z")

</div>

On Tue, May 8, 2012 at 6:17 PM, Dennis [gearond@gmail.com](mailto:gearond@gmail.com) wrote:

> I read in a recent post on this forum that nested data cannot be sorted  
> upon in the query results? Is this true? It'd be a good thing to put on the  
> nested type page 🙂
> 
> It really kills any practical use for my project, alas.

Yes, you can't sort based on nested documents

> Also, what exactly gets returned by default doing nested queries? All of  
> the parent and all of the nested child that matched? Can any of that be  
> controlled?

The full document you indexed is returned, you can pick and choose what  
parts of the document gets returned, but not specific nested document  
elements that matched.

---

<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, 3:29am UTC](https://discuss.elastic.co/t/nested-types-in-queries/7601/3 "2017-07-06T03:29:32Z")

</div>

Closed on July 6, 2017, 3:29am UTC


