# Nested has\_parent query

**URL:** https://discuss.elastic.co/t/nested-has-parent-query/11395
**Category:** Elasticsearch
**Created:** [April 1, 2013, 11:00am UTC](https://discuss.elastic.co/t/nested-has-parent-query/11395 "2013-04-01T11:00:41Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![kul](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kul/32/2158_2.png) [@kul](https://discuss.elastic.co/u/kul)
#### Post date: [April 1, 2013, 11:00am UTC](https://discuss.elastic.co/t/nested-has-parent-query/11395/1 "2013-04-01T11:00:41Z")

</div>

I have the exact same problem as the one previously posted  
[https://groups.google.com/forum/?fromgroups=#!searchin/elasticsearch/has\_parent/elasticsearch/TwqHqOigVJs/FBba9p1ZFc0J](https://groups.google.com/forum/?fromgroups=#!searchin/elasticsearch/has_parent/elasticsearch/TwqHqOigVJs/FBba9p1ZFc0J)

Except that instead of has\_child i am trying to do a has\_parent query.

curl -XPOST [http://localhost:9200/my\_index/grandchild/\_search/](http://localhost:9200/my_index/grandchild/_search/) -d '{  
"query": {  
"has\_parent": {  
"parent\_type": "child",  
"query": {  
"has\_parent": {  
"parent\_type": "parent",  
"query": {  
"match\_all": {}  
}  
}  
}  
}  
}  
}'  
For which i get a empty result.

I have defined routing for grandchild docs and the nested has\_child works  
fine too. Any ideas what i may be doing wrong here?

Thanks

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![mkleen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mkleen/32/1694_2.png) [@mkleen](https://discuss.elastic.co/u/mkleen)
#### Post date: [April 1, 2013, 6:16pm UTC](https://discuss.elastic.co/t/nested-has-parent-query/11395/2 "2013-04-01T18:16:04Z")

</div>

Hi Kul,

Is there any chance you could post a complete example of your problem  
including the mapping ?

Michael

On Monday, April 1, 2013 1:00:41 PM UTC+2, kul wrote:

> I have the exact same problem as the one previously posted  
> [Redirecting to Google Groups](https://groups.google.com/forum/?fromgroups=#!searchin/elasticsearch/has_parent/elasticsearch/TwqHqOigVJs/FBba9p1ZFc0J)
> 
> Except that instead of has\_child i am trying to do a has\_parent query.
> 
> curl -XPOST [http://localhost:9200/my\_index/grandchild/\_search/](http://localhost:9200/my_index/grandchild/_search/) -d '{  
> "query": {  
> "has\_parent": {  
> "parent\_type": "child",  
> "query": {  
> "has\_parent": {  
> "parent\_type": "parent",  
> "query": {  
> "match\_all": {}  
> }  
> }  
> }  
> }  
> }  
> }'  
> For which i get a empty result.
> 
> I have defined routing for grandchild docs and the nested has\_child works  
> fine too. Any ideas what i may be doing wrong here?
> 
> Thanks

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![kul](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kul/32/2158_2.png) [@kul](https://discuss.elastic.co/u/kul)
#### Post date: [April 4, 2013, 3:34am UTC](https://discuss.elastic.co/t/nested-has-parent-query/11395/3 "2013-04-04T03:34:45Z")

</div>

Hi Michael,

Thanks for asking. But it seems i had done some mistake with the data while  
testing, Nested queries work very nicely already.

Thanks

On Monday, April 1, 2013 11:46:04 PM UTC+5:30, mkleen wrote:

> Hi Kul,
> 
> Is there any chance you could post a complete example of your problem  
> including the mapping ?
> 
> Michael
> 
> On Monday, April 1, 2013 1:00:41 PM UTC+2, kul wrote:
> 
> > I have the exact same problem as the one previously posted  
> > [Redirecting to Google Groups](https://groups.google.com/forum/?fromgroups=#!searchin/elasticsearch/has_parent/elasticsearch/TwqHqOigVJs/FBba9p1ZFc0J)
> > 
> > Except that instead of has\_child i am trying to do a has\_parent query.
> > 
> > curl -XPOST [http://localhost:9200/my\_index/grandchild/\_search/](http://localhost:9200/my_index/grandchild/_search/) -d '{  
> > "query": {  
> > "has\_parent": {  
> > "parent\_type": "child",  
> > "query": {  
> > "has\_parent": {  
> > "parent\_type": "parent",  
> > "query": {  
> > "match\_all": {}  
> > }  
> > }  
> > }  
> > }  
> > }  
> > }'  
> > For which i get a empty result.
> > 
> > I have defined routing for grandchild docs and the nested has\_child works  
> > fine too. Any ideas what i may be doing wrong here?
> > 
> > Thanks

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:42am UTC](https://discuss.elastic.co/t/nested-has-parent-query/11395/4 "2017-07-06T02:42:53Z")

</div>


