# NPE Exception in Java client with nested query

**URL:** <https://discuss.elastic.co/t/npe-exception-in-java-client-with-nested-query/11884>\
**Category:** Elasticsearch\
**Created:** [May 8, 2013, 6:38pm UTC](https://discuss.elastic.co/t/npe-exception-in-java-client-with-nested-query/11884 "2013-05-08T18:38:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Bartak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/john_bartak/32/1830_2.png) [@John\_Bartak](https://discuss.elastic.co/u/John_Bartak)\
**Post date:** [May 8, 2013, 6:38pm UTC](https://discuss.elastic.co/t/npe-exception-in-java-client-with-nested-query/11884/1 "2013-05-08T18:38:06Z")

</div>

When I switched over to the 90.0 version from 20.4, I started seeing some  
null pointer exceptions in the Java client from my integration tests. The  
problem is not reproducible using the REST API.

It seems to occur when you do a nested query against multiple indices and  
one of the indices has no documents that match a query (but does have some  
documents in it).

The problem occurs in the AggregatedDfs.writeTo method because of the  
entries in the fieldStatistics map has an entry with a null key.

A highly abbreviated call stack of where the exception occurs:  
at  
org.elasticsearch.common.io.stream.HandlesStreamOutput.writeString(HandlesStreamOutput.java:55)  
at  
org.elasticsearch.search.dfs.AggregatedDfs.writeTo(AggregatedDfs.java:106)  
at  
org.elasticsearch.search.query.QuerySearchRequest.writeTo(QuerySearchRequest.java:69)  
at  
org.elasticsearch.transport.netty.NettyTransport.sendRequest(NettyTransport.java:546)

I've created a Gist that reproduces the problem:

> <https://gist.github.com/bartakj/5542153>

--  
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:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [May 8, 2013, 8:47pm UTC](https://discuss.elastic.co/t/npe-exception-in-java-client-with-nested-query/11884/2 "2013-05-08T20:47:21Z")

</div>

Nice finding, I think it would be a good thing to open an issue on  
github with the full stack trace.

Jörg

Am 08.05.13 20:38, schrieb JBartak:

> When I switched over to the 90.0 version from 20.4, I started seeing  
> some null pointer exceptions in the Java client from my integration  
> tests. The problem is not reproducible using the REST API.
> 
> It seems to occur when you do a nested query against multiple indices  
> and one of the indices has no documents that match a query (but does  
> have some documents in it).
> 
> The problem occurs in the AggregatedDfs.writeTo method because of the  
> entries in the fieldStatistics map has an entry with a null key.
> 
> A highly abbreviated call stack of where the exception occurs:  
> at  
> org.elasticsearch.common.io.stream.HandlesStreamOutput.writeString(HandlesStreamOutput.java:55)  
> at  
> org.elasticsearch.search.dfs.AggregatedDfs.writeTo(AggregatedDfs.java:106)  
> at  
> org.elasticsearch.search.query.QuerySearchRequest.writeTo(QuerySearchRequest.java:69)  
> at  
> org.elasticsearch.transport.netty.NettyTransport.sendRequest(NettyTransport.java:546)
> 
> ## I've created a Gist that reproduces the problem: [ES0.90.0 NPE.txt · GitHub](https://gist.github.com/bartakj/5542153)
> 
> 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).

--  
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:** ![John\_Bartak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/john_bartak/32/1830_2.png) [@John\_Bartak](https://discuss.elastic.co/u/John_Bartak)\
**Post date:** [May 8, 2013, 8:52pm UTC](https://discuss.elastic.co/t/npe-exception-in-java-client-with-nested-query/11884/3 "2013-05-08T20:52:19Z")

</div>

Posted in [https://github.com/elasticsearch/elasticsearch/issues/3014](https://github.com/elasticsearch/elasticsearch/issues/3014)

--  
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:37am UTC](https://discuss.elastic.co/t/npe-exception-in-java-client-with-nested-query/11884/4 "2017-07-06T02:37:33Z")

</div>


