# NPE from server when using query + geo filter + sort

**URL:** <https://discuss.elastic.co/t/npe-from-server-when-using-query-geo-filter-sort/20694>\
**Category:** Elasticsearch\
**Created:** [November 11, 2014, 5:11pm UTC](https://discuss.elastic.co/t/npe-from-server-when-using-query-geo-filter-sort/20694 "2014-11-11T17:11:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Todd\_Nine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/todd_nine/32/778_2.png) [@Todd\_Nine](https://discuss.elastic.co/u/Todd_Nine)\
**Post date:** [November 11, 2014, 5:11pm UTC](https://discuss.elastic.co/t/npe-from-server-when-using-query-geo-filter-sort/20694/1 "2014-11-11T17:11:45Z")

</div>

Hi all,  
I'm getting some strange behavior from the ES server when using a term  
query + a geo distance filter + a sort. I've tried this with 1.3.2,  
1.3.5, as well as 1.4.0. All exhibit this same behavior. I'm using the  
Java transport client. Here is my SearchRequestBuilder payload in  
toString() format.

query { "from" : 0, "size" : 10, "query" : { "term" : {  
"ug\_context" :  
"2abaf75a-69c4-11e4-918e-4658cde16dad\_\_application\_\_zzzcollzzzusers" }  
}, "post\_filter" : { "geo\_distance" : { "go\_location" : [  
-122.40474700927734, 37.77427673339844 ], "distance" : "200.0m" }  
}, "sort" : [ { "su\_created" : { "order" : "asc",  
"ignore\_unmapped" : true } }, { "nu\_created" : { "order" :  
"asc", "ignore\_unmapped" : true } }, { "bu\_created" : {  
"order" : "asc", "ignore\_unmapped" : true } } ] } limit 10

Here is the stack trace

org.elasticsearch.common.util.concurrent.UncategorizedExecutionException:  
Failed execution  
at  
org.elasticsearch.action.support.AdapterActionFuture.rethrowExecutionException(AdapterActionFuture.java:90)  
at  
org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:50)  
at  
org.apache.usergrid.persistence.index.impl.EsEntityIndexImpl.search(EsEntityIndexImpl.java:307)  
at  
org.apache.usergrid.corepersistence.CpRelationManager.searchConnectedEntities(CpRelationManager.java:1453)  
at  
org.apache.usergrid.corepersistence.CpEntityManager.searchConnectedEntities(CpEntityManager.java:1585)  
at org.apache.usergrid.persistence.GeoIT.testGeo(GeoIT.java:202)  
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
at  
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)  
at  
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
at java.lang.reflect.Method.invoke(Method.java:606)  
at  
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)  
at  
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)  
at  
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)  
at  
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)  
at org.apache.usergrid.CoreApplication$1.evaluate(CoreApplication.java:133)  
at org.junit.rules.RunRules.evaluate(RunRules.java:20)  
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)  
at  
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)  
at  
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)  
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)  
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)  
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)  
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)  
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)  
at org.apache.usergrid.CoreITSetupImpl$1.evaluate(CoreITSetupImpl.java:66)  
at org.junit.rules.RunRules.evaluate(RunRules.java:20)  
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)  
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)  
at  
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)  
at  
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)  
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)  
Caused by: java.lang.NullPointerException  
at  
org.elasticsearch.common.io.stream.StreamOutput.writeString(StreamOutput.java:223)  
at  
org.elasticsearch.common.io.stream.HandlesStreamOutput.writeString(HandlesStreamOutput.java:55)  
at  
org.elasticsearch.common.io.stream.StreamOutput.writeStringArray(StreamOutput.java:298)  
at  
org.elasticsearch.action.search.SearchRequest.writeTo(SearchRequest.java:615)  
at  
org.elasticsearch.transport.netty.NettyTransport.sendRequest(NettyTransport.java:685)  
at  
org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:199)  
at  
org.elasticsearch.action.TransportActionNodeProxy.execute(TransportActionNodeProxy.java:57)  
at  
org.elasticsearch.client.transport.support.InternalTransportClient$1.doWithNode(InternalTransportClient.java:109)  
at  
org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:202)  
at  
org.elasticsearch.client.transport.support.InternalTransportClient.execute(InternalTransportClient.java:106)  
at  
org.elasticsearch.client.support.AbstractClient.search(AbstractClient.java:334)  
at  
org.elasticsearch.client.transport.TransportClient.search(TransportClient.java:424)  
at  
org.elasticsearch.action.search.SearchRequestBuilder.doExecute(SearchRequestBuilder.java:1116)  
at  
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)  
at  
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)

I've observed a couple of things. I don't see this exception when there  
are no matching documents. When I do have matching documents, then I see  
the NPE.

Any ideas what I'm doing wrong? The payload itself looks fine, and  
serializes from the builder to a SMILE byte payload. However, when that  
payload is transmitted over Netty, I see this exception.

Thanks,  
Todd

--  
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/23b8befe-e62c-49b6-a9e5-1394e741f55d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/23b8befe-e62c-49b6-a9e5-1394e741f55d%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Todd\_Nine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/todd_nine/32/778_2.png) [@Todd\_Nine](https://discuss.elastic.co/u/Todd_Nine)\
**Post date:** [November 11, 2014, 6:09pm UTC](https://discuss.elastic.co/t/npe-from-server-when-using-query-geo-filter-sort/20694/2 "2014-11-11T18:09:11Z")

</div>

I just noticed I had a typo in my query, this is the query payload I'm  
executing if I run it in HTTP (which works)

{  
"from" : 0,  
"size" : 10,  
"query" : {  
"term" : {  
"ug\_context" :  
"c2d2d78a-69cc-11e4-b22e-81db7b9aa660\_\_user\_\_zzzconnzzzlikes"  
}  
},

```
    "post_filter" : {    
         "geo_distance" : {    
            "go_location" : [-122.40474700927734, 37.77427673339844], 
  
            "distance" : "200.0m" }  
     },  
     
     "sort" : [ 
        { "su_created" : 
            { "order" : "asc",      
                     "ignore_unmapped" : true     
            }  
         }, 
         
         { "nu_created" : 
            { "order" : "asc",      
                 "ignore_unmapped" : true     
            }  
        }, 
        {    
             "bu_created" : {    
                   "order" : "asc",      
                     "ignore_unmapped" : true     
                    } 
         } 
    ]
}

```

On Tuesday, November 11, 2014 10:11:46 AM UTC-7, Todd Nine wrote:

> Hi all,  
> I'm getting some strange behavior from the ES server when using a term  
> query + a geo distance filter + a sort. I've tried this with 1.3.2,  
> 1.3.5, as well as 1.4.0. All exhibit this same behavior. I'm using the  
> Java transport client. Here is my SearchRequestBuilder payload in  
> toString() format.
> 
> query { "from" : 0, "size" : 10, "query" : { "term" : {  
> "ug\_context" :  
> "2abaf75a-69c4-11e4-918e-4658cde16dad\_\_application\_\_zzzcollzzzusers" }  
> }, "post\_filter" : { "geo\_distance" : { "go\_location" : [  
> -122.40474700927734, 37.77427673339844 ], "distance" : "200.0m" }  
> }, "sort" : [ { "su\_created" : { "order" : "asc",  
> "ignore\_unmapped" : true } }, { "nu\_created" : { "order" :  
> "asc", "ignore\_unmapped" : true } }, { "bu\_created" : {  
> "order" : "asc", "ignore\_unmapped" : true } } ] } limit 10
> 
> Here is the stack trace
> 
> org.elasticsearch.common.util.concurrent.UncategorizedExecutionException:  
> Failed execution  
> at  
> org.elasticsearch.action.support.AdapterActionFuture.rethrowExecutionException(AdapterActionFuture.java:90)  
> at  
> org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:50)  
> at  
> org.apache.usergrid.persistence.index.impl.EsEntityIndexImpl.search(EsEntityIndexImpl.java:307)  
> at  
> org.apache.usergrid.corepersistence.CpRelationManager.searchConnectedEntities(CpRelationManager.java:1453)  
> at  
> org.apache.usergrid.corepersistence.CpEntityManager.searchConnectedEntities(CpEntityManager.java:1585)  
> at org.apache.usergrid.persistence.GeoIT.testGeo(GeoIT.java:202)  
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
> at  
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)  
> at  
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
> at java.lang.reflect.Method.invoke(Method.java:606)  
> at  
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)  
> at  
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)  
> at  
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)  
> at  
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)  
> at org.apache.usergrid.CoreApplication$1.evaluate(CoreApplication.java:133)  
> at org.junit.rules.RunRules.evaluate(RunRules.java:20)  
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)  
> at  
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)  
> at  
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)  
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)  
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)  
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)  
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)  
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)  
> at org.apache.usergrid.CoreITSetupImpl$1.evaluate(CoreITSetupImpl.java:66)  
> at org.junit.rules.RunRules.evaluate(RunRules.java:20)  
> at org.junit.runners.ParentRunner.run(ParentRunner.java:309)  
> at org.junit.runner.JUnitCore.run(JUnitCore.java:160)  
> at  
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)  
> at  
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)  
> at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)  
> Caused by: java.lang.NullPointerException  
> at  
> org.elasticsearch.common.io.stream.StreamOutput.writeString(StreamOutput.java:223)  
> at  
> org.elasticsearch.common.io.stream.HandlesStreamOutput.writeString(HandlesStreamOutput.java:55)  
> at  
> org.elasticsearch.common.io.stream.StreamOutput.writeStringArray(StreamOutput.java:298)  
> at  
> org.elasticsearch.action.search.SearchRequest.writeTo(SearchRequest.java:615)  
> at  
> org.elasticsearch.transport.netty.NettyTransport.sendRequest(NettyTransport.java:685)  
> at  
> org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:199)  
> at  
> org.elasticsearch.action.TransportActionNodeProxy.execute(TransportActionNodeProxy.java:57)  
> at  
> org.elasticsearch.client.transport.support.InternalTransportClient$1.doWithNode(InternalTransportClient.java:109)  
> at  
> org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:202)  
> at  
> org.elasticsearch.client.transport.support.InternalTransportClient.execute(InternalTransportClient.java:106)  
> at  
> org.elasticsearch.client.support.AbstractClient.search(AbstractClient.java:334)  
> at  
> org.elasticsearch.client.transport.TransportClient.search(TransportClient.java:424)  
> at  
> org.elasticsearch.action.search.SearchRequestBuilder.doExecute(SearchRequestBuilder.java:1116)  
> at  
> org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)  
> at  
> org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)
> 
> I've observed a couple of things. I don't see this exception when there  
> are no matching documents. When I do have matching documents, then I see  
> the NPE.
> 
> Any ideas what I'm doing wrong? The payload itself looks fine, and  
> serializes from the builder to a SMILE byte payload. However, when that  
> payload is transmitted over Netty, I see this exception.
> 
> Thanks,  
> Todd

--  
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/d0a099cb-57af-4800-a4b2-458a9fa29f4b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d0a099cb-57af-4800-a4b2-458a9fa29f4b%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [November 11, 2014, 7:47pm UTC](https://discuss.elastic.co/t/npe-from-server-when-using-query-geo-filter-sort/20694/3 "2014-11-11T19:47:53Z")

</div>

Looks like a bug in org.apache.usergrid.persistence.index.impl.  
EsEntityIndexImpl

Check if the "types" are set to a non-null value in the SearchRequest. If  
you force them to be a null value, SearchRequest will throw the NPE you  
posted.

Jörg

On Tue, Nov 11, 2014 at 6:11 PM, Todd Nine [tnine@apigee.com](mailto:tnine@apigee.com) wrote:

> Hi all,  
> I'm getting some strange behavior from the ES server when using a term  
> query + a geo distance filter + a sort. I've tried this with 1.3.2,  
> 1.3.5, as well as 1.4.0. All exhibit this same behavior. I'm using the  
> Java transport client. Here is my SearchRequestBuilder payload in  
> toString() format.
> 
> query { "from" : 0, "size" : 10, "query" : { "term" : {  
> "ug\_context" :  
> "2abaf75a-69c4-11e4-918e-4658cde16dad\_\_application\_\_zzzcollzzzusers" }  
> }, "post\_filter" : { "geo\_distance" : { "go\_location" : [  
> -122.40474700927734, 37.77427673339844 ], "distance" : "200.0m" }  
> }, "sort" : [ { "su\_created" : { "order" : "asc",  
> "ignore\_unmapped" : true } }, { "nu\_created" : { "order" :  
> "asc", "ignore\_unmapped" : true } }, { "bu\_created" : {  
> "order" : "asc", "ignore\_unmapped" : true } } ] } limit 10
> 
> Here is the stack trace
> 
> org.elasticsearch.common.util.concurrent.UncategorizedExecutionException:  
> Failed execution  
> at  
> org.elasticsearch.action.support.AdapterActionFuture.rethrowExecutionException(AdapterActionFuture.java:90)  
> at  
> org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:50)  
> at  
> org.apache.usergrid.persistence.index.impl.EsEntityIndexImpl.search(EsEntityIndexImpl.java:307)  
> at  
> org.apache.usergrid.corepersistence.CpRelationManager.searchConnectedEntities(CpRelationManager.java:1453)  
> at  
> org.apache.usergrid.corepersistence.CpEntityManager.searchConnectedEntities(CpEntityManager.java:1585)  
> at org.apache.usergrid.persistence.GeoIT.testGeo(GeoIT.java:202)  
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
> at  
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)  
> at  
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
> at java.lang.reflect.Method.invoke(Method.java:606)  
> at  
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)  
> at  
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)  
> at  
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)  
> at  
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)  
> at org.apache.usergrid.CoreApplication$1.evaluate(CoreApplication.java:133)  
> at org.junit.rules.RunRules.evaluate(RunRules.java:20)  
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)  
> at  
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)  
> at  
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)  
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)  
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)  
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)  
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)  
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)  
> at org.apache.usergrid.CoreITSetupImpl$1.evaluate(CoreITSetupImpl.java:66)  
> at org.junit.rules.RunRules.evaluate(RunRules.java:20)  
> at org.junit.runners.ParentRunner.run(ParentRunner.java:309)  
> at org.junit.runner.JUnitCore.run(JUnitCore.java:160)  
> at  
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)  
> at  
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)  
> at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)  
> Caused by: java.lang.NullPointerException  
> at  
> org.elasticsearch.common.io.stream.StreamOutput.writeString(StreamOutput.java:223)  
> at  
> org.elasticsearch.common.io.stream.HandlesStreamOutput.writeString(HandlesStreamOutput.java:55)  
> at  
> org.elasticsearch.common.io.stream.StreamOutput.writeStringArray(StreamOutput.java:298)  
> at  
> org.elasticsearch.action.search.SearchRequest.writeTo(SearchRequest.java:615)  
> at  
> org.elasticsearch.transport.netty.NettyTransport.sendRequest(NettyTransport.java:685)  
> at  
> org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:199)  
> at  
> org.elasticsearch.action.TransportActionNodeProxy.execute(TransportActionNodeProxy.java:57)  
> at  
> org.elasticsearch.client.transport.support.InternalTransportClient$1.doWithNode(InternalTransportClient.java:109)  
> at  
> org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:202)  
> at  
> org.elasticsearch.client.transport.support.InternalTransportClient.execute(InternalTransportClient.java:106)  
> at  
> org.elasticsearch.client.support.AbstractClient.search(AbstractClient.java:334)  
> at  
> org.elasticsearch.client.transport.TransportClient.search(TransportClient.java:424)  
> at  
> org.elasticsearch.action.search.SearchRequestBuilder.doExecute(SearchRequestBuilder.java:1116)  
> at  
> org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)  
> at  
> org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)
> 
> I've observed a couple of things. I don't see this exception when there  
> are no matching documents. When I do have matching documents, then I see  
> the NPE.
> 
> Any ideas what I'm doing wrong? The payload itself looks fine, and  
> serializes from the builder to a SMILE byte payload. However, when that  
> payload is transmitted over Netty, I see this exception.
> 
> Thanks,  
> Todd
> 
> --  
> 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/23b8befe-e62c-49b6-a9e5-1394e741f55d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/23b8befe-e62c-49b6-a9e5-1394e741f55d%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/23b8befe-e62c-49b6-a9e5-1394e741f55d%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/23b8befe-e62c-49b6-a9e5-1394e741f55d%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAKdsXoEcQ8hBkjCQxp3MvwQbigcy\_rA2xaPZKSc1LvQ%2BB1UeTQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEcQ8hBkjCQxp3MvwQbigcy_rA2xaPZKSc1LvQ%2BB1UeTQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Todd\_Nine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/todd_nine/32/778_2.png) [@Todd\_Nine](https://discuss.elastic.co/u/Todd_Nine)\
**Post date:** [November 11, 2014, 9:40pm UTC](https://discuss.elastic.co/t/npe-from-server-when-using-query-geo-filter-sort/20694/4 "2014-11-11T21:40:33Z")

</div>

You're right Jorg. There was an issue where types was incorrectly set to  
null because more than 1 was specified. As a result, it passed the check  
for at least 1 element in the array, even though the type itself in element  
0 was null. Thank you for your help!

On Tuesday, November 11, 2014 12:48:22 PM UTC-7, Jörg Prante wrote:

> Looks like a bug in org.apache.usergrid.persistence.index.impl.  
> EsEntityIndexImpl
> 
> Check if the "types" are set to a non-null value in the SearchRequest. If  
> you force them to be a null value, SearchRequest will throw the NPE you  
> posted.
> 
> Jörg
> 
> On Tue, Nov 11, 2014 at 6:11 PM, Todd Nine \<[tn...@apigee.com](mailto:tn...@apigee.com) \<javascript:\>
> 
> > wrote:
> 
> > Hi all,  
> > I'm getting some strange behavior from the ES server when using a term  
> > query + a geo distance filter + a sort. I've tried this with 1.3.2,  
> > 1.3.5, as well as 1.4.0. All exhibit this same behavior. I'm using the  
> > Java transport client. Here is my SearchRequestBuilder payload in  
> > toString() format.
> > 
> > query { "from" : 0, "size" : 10, "query" : { "term" : {  
> > "ug\_context" :  
> > "2abaf75a-69c4-11e4-918e-4658cde16dad\_\_application\_\_zzzcollzzzusers" }  
> > }, "post\_filter" : { "geo\_distance" : { "go\_location" : [  
> > -122.40474700927734, 37.77427673339844 ], "distance" : "200.0m" }  
> > }, "sort" : [ { "su\_created" : { "order" : "asc",  
> > "ignore\_unmapped" : true } }, { "nu\_created" : { "order" :  
> > "asc", "ignore\_unmapped" : true } }, { "bu\_created" : {  
> > "order" : "asc", "ignore\_unmapped" : true } } ] } limit 10
> > 
> > Here is the stack trace
> > 
> > org.elasticsearch.common.util.concurrent.UncategorizedExecutionException:  
> > Failed execution  
> > at  
> > org.elasticsearch.action.support.AdapterActionFuture.rethrowExecutionException(AdapterActionFuture.java:90)  
> > at  
> > org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:50)  
> > at  
> > org.apache.usergrid.persistence.index.impl.EsEntityIndexImpl.search(EsEntityIndexImpl.java:307)  
> > at  
> > org.apache.usergrid.corepersistence.CpRelationManager.searchConnectedEntities(CpRelationManager.java:1453)  
> > at  
> > org.apache.usergrid.corepersistence.CpEntityManager.searchConnectedEntities(CpEntityManager.java:1585)  
> > at org.apache.usergrid.persistence.GeoIT.testGeo(GeoIT.java:202)  
> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
> > at  
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)  
> > at  
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
> > at java.lang.reflect.Method.invoke(Method.java:606)  
> > at  
> > org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)  
> > at  
> > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)  
> > at  
> > org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)  
> > at  
> > org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)  
> > at  
> > org.apache.usergrid.CoreApplication$1.evaluate(CoreApplication.java:133)  
> > at org.junit.rules.RunRules.evaluate(RunRules.java:20)  
> > at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)  
> > at  
> > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)  
> > at  
> > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)  
> > at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)  
> > at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)  
> > at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)  
> > at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)  
> > at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)  
> > at org.apache.usergrid.CoreITSetupImpl$1.evaluate(CoreITSetupImpl.java:66)  
> > at org.junit.rules.RunRules.evaluate(RunRules.java:20)  
> > at org.junit.runners.ParentRunner.run(ParentRunner.java:309)  
> > at org.junit.runner.JUnitCore.run(JUnitCore.java:160)  
> > at  
> > com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)  
> > at  
> > com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)  
> > at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)  
> > Caused by: java.lang.NullPointerException  
> > at  
> > org.elasticsearch.common.io.stream.StreamOutput.writeString(StreamOutput.java:223)  
> > at  
> > org.elasticsearch.common.io.stream.HandlesStreamOutput.writeString(HandlesStreamOutput.java:55)  
> > at  
> > org.elasticsearch.common.io.stream.StreamOutput.writeStringArray(StreamOutput.java:298)  
> > at  
> > org.elasticsearch.action.search.SearchRequest.writeTo(SearchRequest.java:615)  
> > at  
> > org.elasticsearch.transport.netty.NettyTransport.sendRequest(NettyTransport.java:685)  
> > at  
> > org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:199)  
> > at  
> > org.elasticsearch.action.TransportActionNodeProxy.execute(TransportActionNodeProxy.java:57)  
> > at  
> > org.elasticsearch.client.transport.support.InternalTransportClient$1.doWithNode(InternalTransportClient.java:109)  
> > at  
> > org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:202)  
> > at  
> > org.elasticsearch.client.transport.support.InternalTransportClient.execute(InternalTransportClient.java:106)  
> > at  
> > org.elasticsearch.client.support.AbstractClient.search(AbstractClient.java:334)  
> > at  
> > org.elasticsearch.client.transport.TransportClient.search(TransportClient.java:424)  
> > at  
> > org.elasticsearch.action.search.SearchRequestBuilder.doExecute(SearchRequestBuilder.java:1116)  
> > at  
> > org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:91)  
> > at  
> > org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:65)
> > 
> > I've observed a couple of things. I don't see this exception when there  
> > are no matching documents. When I do have matching documents, then I see  
> > the NPE.
> > 
> > Any ideas what I'm doing wrong? The payload itself looks fine, and  
> > serializes from the builder to a SMILE byte payload. However, when that  
> > payload is transmitted over Netty, I see this exception.
> > 
> > Thanks,  
> > Todd
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/23b8befe-e62c-49b6-a9e5-1394e741f55d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/23b8befe-e62c-49b6-a9e5-1394e741f55d%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/23b8befe-e62c-49b6-a9e5-1394e741f55d%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/23b8befe-e62c-49b6-a9e5-1394e741f55d%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/e9a6c8fb-4aa3-4ed3-abaf-0d7dcae9cc10%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e9a6c8fb-4aa3-4ed3-abaf-0d7dcae9cc10%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, 12:50am UTC](https://discuss.elastic.co/t/npe-from-server-when-using-query-geo-filter-sort/20694/5 "2017-07-06T00:50:42Z")

</div>


