# Nested: NullPointerException during has parent query

**URL:** <https://discuss.elastic.co/t/nested-nullpointerexception-during-has-parent-query/14063>\
**Category:** Elasticsearch\
**Created:** [October 22, 2013, 10:47pm UTC](https://discuss.elastic.co/t/nested-nullpointerexception-during-has-parent-query/14063 "2013-10-22T22:47:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![VB1](https://avatars.discourse-cdn.com/v4/letter/v/2acd7d/32.png) [@VB1](https://discuss.elastic.co/u/VB1)\
**Post date:** [October 22, 2013, 10:47pm UTC](https://discuss.elastic.co/t/nested-nullpointerexception-during-has-parent-query/14063/1 "2013-10-22T22:47:32Z")

</div>

I am having weird issue

[http://localhost:9200/1\_exposureindex/riskitemsearch/\_search/](http://localhost:9200/1_exposureindex/riskitemsearch/_search/)

{  
"query": {  
"has\_parent": {  
"parent\_type": "contractsearch",  
"query": {  
"term": {  
"Name": "4l4"  
}  
}  
}  
}  
}

when I execute this query I get null pointer exception

{

- error: SearchPhaseExecutionException[Failed to execute phase [query],  
total failure; shardFailures {[zohpYnUKQNSpROOg6eER9Q][1\_exposureindex][1]:  
SearchParseException[[1\_exposureindex][1]: from[-1],size[-1]: Parse Failure  
[Failed to parse source  
[{"query":{"has\_parent":{"parent\_type":"contractsearch","query":{"term":{"Name":"4l4"}}}}}]]];  
nested: NullPointerException;  
}{[zohpYnUKQNSpROOg6eER9Q][1\_exposureindex][0]:  
SearchParseException[[1\_exposureindex][0]: from[-1],size[-1]: Parse Failure  
[Failed to parse source  
[{"query":{"has\_parent":{"parent\_type":"contractsearch","query":{"term":{"Name":"4l4"}}}}}]]];  
nested: NullPointerException; }]
- status: 500

}

but same query works when I do has\_child

e.g.  
[http://localhost:9200/1\_exposureindex/contractsearch/\_search/](http://localhost:9200/1_exposureindex/contractsearch/_search/)

{  
"query": {  
"has\_child": {  
"type": "riskitemsearch",  
"query": {  
"term": {  
"Name": "4l4"  
}  
}  
}  
}  
}

Please help.

--  
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:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [October 23, 2013, 8:48am UTC](https://discuss.elastic.co/t/nested-nullpointerexception-during-has-parent-query/14063/2 "2013-10-23T08:48:39Z")

</div>

HI,  
as mentioned in the same stackoverflow question you posted, it would be  
useful to have a complete curl recreation that includes a few documents  
that you indexed to reproduce the problem.  
Can you send that please?

Cheers  
Luca

On Wednesday, October 23, 2013 12:47:32 AM UTC+2, VB wrote:

> I am having weird issue
> 
> [http://localhost:9200/1\_exposureindex/riskitemsearch/\_search/](http://localhost:9200/1_exposureindex/riskitemsearch/_search/)
> 
> {  
> "query": {  
> "has\_parent": {  
> "parent\_type": "contractsearch",  
> "query": {  
> "term": {  
> "Name": "4l4"  
> }  
> }  
> }  
> }  
> }
> 
> when I execute this query I get null pointer exception
> 
> {
> 
> - error: SearchPhaseExecutionException[Failed to execute phase  
> [query], total failure; shardFailures  
> {[zohpYnUKQNSpROOg6eER9Q][1\_exposureindex][1]:  
> SearchParseException[[1\_exposureindex][1]: from[-1],size[-1]: Parse Failure  
> [Failed to parse source  
> [{"query":{"has\_parent":{"parent\_type":"contractsearch","query":{"term":{"Name":"4l4"}}}}}]]];  
> nested: NullPointerException;  
> }{[zohpYnUKQNSpROOg6eER9Q][1\_exposureindex][0]:  
> SearchParseException[[1\_exposureindex][0]: from[-1],size[-1]: Parse Failure  
> [Failed to parse source  
> [{"query":{"has\_parent":{"parent\_type":"contractsearch","query":{"term":{"Name":"4l4"}}}}}]]];  
> nested: NullPointerException; }]
> - status: 500
> 
> }
> 
> but same query works when I do has\_child
> 
> e.g.  
> [http://localhost:9200/1\_exposureindex/contractsearch/\_search/](http://localhost:9200/1_exposureindex/contractsearch/_search/)
> 
> {  
> "query": {  
> "has\_child": {  
> "type": "riskitemsearch",  
> "query": {  
> "term": {  
> "Name": "4l4"  
> }  
> }  
> }  
> }  
> }
> 
> Please help.

--  
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:11am UTC](https://discuss.elastic.co/t/nested-nullpointerexception-during-has-parent-query/14063/3 "2017-07-06T02:11:04Z")

</div>


