# Feature requests: alias for types and support multiple child types in has\_child/top\_child queries

**URL:** https://discuss.elastic.co/t/feature-requests-alias-for-types-and-support-multiple-child-types-in-has-child-top-child-queries/10051
**Category:** Elasticsearch
**Created:** [December 12, 2012, 4:59am UTC](https://discuss.elastic.co/t/feature-requests-alias-for-types-and-support-multiple-child-types-in-has-child-top-child-queries/10051 "2012-12-12T04:59:45Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Junjun\_Zhang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/junjun_zhang/32/45613_2.png) [@Junjun\_Zhang](https://discuss.elastic.co/u/Junjun_Zhang)
#### Post date: [December 12, 2012, 4:59am UTC](https://discuss.elastic.co/t/feature-requests-alias-for-types-and-support-multiple-child-types-in-has-child-top-child-queries/10051/1 "2012-12-12T04:59:45Z")

</div>

Dear all,

I have been trying out ElasticSearch parent-child relation index. In our  
use case, the parent type is relatively small while the child type can be  
very large. It seems beneficial for index creation/maintenance to break up  
the child type into multiple small types. The problem is that 'top\_child'  
and 'has\_child' queries do not allow more than one child type to be used  
although specifying multiple types works like a charm in a usual query.

So my question is: if specifying multiple child types in  
has\_child/top\_child queries is not supported, is it reasonably easy to  
implement? This seems to be a logic extension of the current support for  
query against multiple types. It should be a useful feature to many others,  
and better yet, if aliases are allowed to be created for types, with this  
we can simply use an alias as child\_type in the has\_child/top\_child  
queries, behind the scene queries are fired against multiple child types.

Many thanks in advance!

Junjun

--

---

<div class="post-metadata">

### Author: ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)
#### Post date: [December 15, 2012, 8:37pm UTC](https://discuss.elastic.co/t/feature-requests-alias-for-types-and-support-multiple-child-types-in-has-child-top-child-queries/10051/2 "2012-12-15T20:37:16Z")

</div>

For has\_children, you can get this functionality now by  
combining multiple has\_child queries together by a boolean query. In case  
of top\_children it's somewhat difficult - you can try using the same  
approach, but it might produce slightly different result in terms  
of scoring.

On Tuesday, December 11, 2012 8:59:45 PM UTC-8, Junjun Zhang wrote:

> Dear all,
> 
> I have been trying out Elasticsearch parent-child relation index. In our  
> use case, the parent type is relatively small while the child type can be  
> very large. It seems beneficial for index creation/maintenance to break up  
> the child type into multiple small types. The problem is that 'top\_child'  
> and 'has\_child' queries do not allow more than one child type to be used  
> although specifying multiple types works like a charm in a usual query.
> 
> So my question is: if specifying multiple child types in  
> has\_child/top\_child queries is not supported, is it reasonably easy to  
> implement? This seems to be a logic extension of the current support for  
> query against multiple types. It should be a useful feature to many others,  
> and better yet, if aliases are allowed to be created for types, with this  
> we can simply use an alias as child\_type in the has\_child/top\_child  
> queries, behind the scene queries are fired against multiple child types.
> 
> Many thanks in advance!
> 
> Junjun

--

---

<div class="post-metadata">

### Author: ![Junjun\_Zhang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/junjun_zhang/32/45613_2.png) [@Junjun\_Zhang](https://discuss.elastic.co/u/Junjun_Zhang)
#### Post date: [December 16, 2012, 6:53pm UTC](https://discuss.elastic.co/t/feature-requests-alias-for-types-and-support-multiple-child-types-in-has-child-top-child-queries/10051/3 "2012-12-16T18:53:13Z")

</div>

Thanks for the suggestions. I will definitely test it out and update the  
list how it went in case some might be interested to know. It would be nice  
this will be supported natively.  
Junjun  
On Dec 15, 2012 3:37 PM, "Igor Motov" [imotov@gmail.com](mailto:imotov@gmail.com) wrote:

> For has\_children, you can get this functionality now by  
> combining multiple has\_child queries together by a boolean query. In case  
> of top\_children it's somewhat difficult - you can try using the same  
> approach, but it might produce slightly different result in terms  
> of scoring.
> 
> On Tuesday, December 11, 2012 8:59:45 PM UTC-8, Junjun Zhang wrote:
> 
> > Dear all,
> > 
> > I have been trying out Elasticsearch parent-child relation index. In our  
> > use case, the parent type is relatively small while the child type can be  
> > very large. It seems beneficial for index creation/maintenance to break up  
> > the child type into multiple small types. The problem is that 'top\_child'  
> > and 'has\_child' queries do not allow more than one child type to be used  
> > although specifying multiple types works like a charm in a usual query.
> > 
> > So my question is: if specifying multiple child types in  
> > has\_child/top\_child queries is not supported, is it reasonably easy to  
> > implement? This seems to be a logic extension of the current support for  
> > query against multiple types. It should be a useful feature to many others,  
> > and better yet, if aliases are allowed to be created for types, with this  
> > we can simply use an alias as child\_type in the has\_child/top\_child  
> > queries, behind the scene queries are fired against multiple child types.
> > 
> > Many thanks in advance!
> > 
> > Junjun
> > 
> > --

--

---

<div class="post-metadata">

### Author: ![btiernay](https://avatars.discourse-cdn.com/v4/letter/b/bb73d2/32.png) [@btiernay](https://discuss.elastic.co/u/btiernay)
#### Post date: [January 22, 2013, 2:41am UTC](https://discuss.elastic.co/t/feature-requests-alias-for-types-and-support-multiple-child-types-in-has-child-top-child-queries/10051/4 "2013-01-22T02:41:35Z")

</div>

I too am very interested in this feature. As Junjun mentions, this would  
help separate type management from query specification. Correct me if I'm  
wrong, but since specifying multiple types is already supported wouldn't  
this be a relatively easy feature to implement?

Thanks again!

--

---

<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, 2:55am UTC](https://discuss.elastic.co/t/feature-requests-alias-for-types-and-support-multiple-child-types-in-has-child-top-child-queries/10051/5 "2017-07-06T02:55:19Z")

</div>


