# Restricting child result

**URL:** https://discuss.elastic.co/t/restricting-child-result/4758
**Category:** Elasticsearch
**Created:** [July 3, 2011, 5:14am UTC](https://discuss.elastic.co/t/restricting-child-result/4758 "2011-07-03T05:14:40Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![khoan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/khoan/32/3187_2.png) [@khoan](https://discuss.elastic.co/u/khoan)
#### Post date: [July 3, 2011, 5:14am UTC](https://discuss.elastic.co/t/restricting-child-result/4758/1 "2011-07-03T05:14:40Z")

</div>

index:

{  
parent\_field: "this is a parent",  
children: [  
{child\_field: 12.3},  
{child\_field: 9.6},  
{child\_field: 4.5}  
]  
}

Now when I search children.child\_field: [1.3 TO 4.6], I would get the whole document including all children. Is it possible to just retrieve the document with children which matches search criteria, that is:

expecting:

{  
parent\_field: "this is a parent",  
children: [  
{child\_field: 4.5}  
]  
}

instead of:

{  
parent\_field: "this is a parent",  
children: [  
{child\_field: 12.3},  
{child\_field: 9.6},  
{child\_field: 4.5}  
]  
}

Cheers.

---

<div class="post-metadata">

### Author: ![Ludovic](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@Ludovic](https://discuss.elastic.co/u/Ludovic)
#### Post date: [July 5, 2011, 9:34am UTC](https://discuss.elastic.co/t/restricting-child-result/4758/2 "2011-07-05T09:34:36Z")

</div>

hi

i have the same trouble. how to show the children filtered ?

tx

On 3 juil, 07:14, khoan [huukhoangu...@hotmail.com](mailto:huukhoangu...@hotmail.com) wrote:

> index:
> 
> {  
> parent\_field: "this is a parent",  
> children: [  
> {child\_field: 12.3},  
> {child\_field: 9.6},  
> {child\_field: 4.5}  
> ]
> 
> }
> 
> Now when I search children.child\_field: [1.3 TO 4.6], I would get the whole  
> document including all children. Is it possible to just retrieve the  
> document with children which matches search criteria, that is:
> 
> expecting:
> 
> {  
> parent\_field: "this is a parent",  
> children: [  
> {child\_field: 4.5}  
> ]
> 
> }
> 
> instead of:
> 
> {  
> parent\_field: "this is a parent",  
> children: [  
> {child\_field: 12.3},  
> {child\_field: 9.6},  
> {child\_field: 4.5}  
> ]
> 
> }
> 
> Cheers.
> 
> --  
> View this message in context:[http://elasticsearch-users.115913.n3.nabble.com/Restricting-child-res](http://elasticsearch-users.115913.n3.nabble.com/Restricting-child-res)...  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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: [July 5, 2011, 11:06am UTC](https://discuss.elastic.co/t/restricting-child-result/4758/3 "2011-07-05T11:06:01Z")

</div>

No, there isn't a way to do it unless you index each child document on its own.

On Tuesday, July 5, 2011 at 12:34 PM, Ludovic wrote:

> hi
> 
> i have the same trouble. how to show the children filtered ?
> 
> tx
> 
> On 3 juil, 07:14, khoan \<[huukhoangu...@hotmail.com](mailto:huukhoangu...@hotmail.com) ([http://hotmail.com](http://hotmail.com))\> wrote:
> 
> > index:
> > 
> > {  
> > parent\_field: "this is a parent",  
> > children: [  
> > {child\_field: 12.3},  
> > {child\_field: 9.6},  
> > {child\_field: 4.5}  
> > ]
> > 
> > }
> > 
> > Now when I search children.child\_field: [1.3 TO 4.6], I would get the whole  
> > document including all children. Is it possible to just retrieve the  
> > document with children which matches search criteria, that is:
> > 
> > expecting:
> > 
> > {  
> > parent\_field: "this is a parent",  
> > children: [  
> > {child\_field: 4.5}  
> > ]
> > 
> > }
> > 
> > instead of:
> > 
> > {  
> > parent\_field: "this is a parent",  
> > children: [  
> > {child\_field: 12.3},  
> > {child\_field: 9.6},  
> > {child\_field: 4.5}  
> > ]
> > 
> > }
> > 
> > Cheers.
> > 
> > --  
> > View this message in context:[http://elasticsearch-users.115913.n3.nabble.com/Restricting-child-res](http://elasticsearch-users.115913.n3.nabble.com/Restricting-child-res)...  
> > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com) ([http://Nabble.com](http://Nabble.com)).

---

<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, 4:01am UTC](https://discuss.elastic.co/t/restricting-child-result/4758/4 "2017-07-06T04:01:45Z")

</div>


