# I need to query parent which has not child attach to it

**URL:** <https://discuss.elastic.co/t/i-need-to-query-parent-which-has-not-child-attach-to-it/18133>\
**Category:** Elasticsearch\
**Created:** [June 16, 2014, 1:25pm UTC](https://discuss.elastic.co/t/i-need-to-query-parent-which-has-not-child-attach-to-it/18133 "2014-06-16T13:25:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ayache\_Khettar](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@Ayache\_Khettar](https://discuss.elastic.co/u/Ayache_Khettar)\
**Post date:** [June 16, 2014, 1:25pm UTC](https://discuss.elastic.co/t/i-need-to-query-parent-which-has-not-child-attach-to-it/18133/1 "2014-06-16T13:25:07Z")

</div>

Hi

The below query search for all entries in a index which has child with the  
given stepUUID. I am interested to search for all entries which don't have  
child item populated yet. I was looking at using 'must\_not" but not sure  
how to construct the query. Your help is very much appreciated.

Regards,

akhettar

{  
"query": {  
"match": {  
"stepUUID": "fd7a5c5d-5254-4941-9c8a-e19a39be86b0"  
}  
},  
"filter": {  
"has\_child": {  
"type": "redelivery",  
"query" : {  
"match": {  
"stepUUID": {  
"query" : "fd7a5c5d-5254-4941-9c8a-e19a39be86b0",  
"operator" : "and"  
}  
}  
}  
}  
}  
}

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b02a052c-bb25-432a-abd1-aae8f77cac15%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b02a052c-bb25-432a-abd1-aae8f77cac15%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ayache\_Khettar](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@Ayache\_Khettar](https://discuss.elastic.co/u/Ayache_Khettar)\
**Post date:** [June 19, 2014, 11:25am UTC](https://discuss.elastic.co/t/i-need-to-query-parent-which-has-not-child-attach-to-it/18133/2 "2014-06-19T11:25:10Z")

</div>

Hi

I am replying to my query I sent last week for the benefit of all. Here is  
the answer:

{  
"query": {  
"match": {"status" : "ERROR"}  
},  
"filter": {  
"not":{  
"filter":{  
"has\_child": {  
"type": "redelivery",  
"query" : {  
"match\_all": {}  
}  
}  
}  
}  
}  
}  
}

All the best

Ayache

On Monday, June 16, 2014 2:25:07 PM UTC+1, Ayache Khettar wrote:

> Hi
> 
> The below query search for all entries in a index which has child with the  
> given stepUUID. I am interested to search for all entries which don't have  
> child item populated yet. I was looking at using 'must\_not" but not sure  
> how to construct the query. Your help is very much appreciated.
> 
> Regards,
> 
> akhettar
> 
> {  
> "query": {  
> "match": {  
> "stepUUID": "fd7a5c5d-5254-4941-9c8a-e19a39be86b0"  
> }  
> },  
> "filter": {  
> "has\_child": {  
> "type": "redelivery",  
> "query" : {  
> "match": {  
> "stepUUID": {  
> "query" : "fd7a5c5d-5254-4941-9c8a-e19a39be86b0",  
> "operator" : "and"  
> }  
> }  
> }  
> }  
> }  
> }

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2656ef48-ce23-442e-b440-1a3d39ea0494%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2656ef48-ce23-442e-b440-1a3d39ea0494%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:21am UTC](https://discuss.elastic.co/t/i-need-to-query-parent-which-has-not-child-attach-to-it/18133/3 "2017-07-06T01:21:12Z")

</div>

Closed on July 6, 2017, 1:21am UTC


