# Elasticsearch Query if point falls within a list of Geocircles Null pointer exception

**URL:** <https://discuss.elastic.co/t/elasticsearch-query-if-point-falls-within-a-list-of-geocircles-null-pointer-exception/83297>\
**Category:** Elasticsearch\
**Created:** [April 22, 2017, 9:31pm UTC](https://discuss.elastic.co/t/elasticsearch-query-if-point-falls-within-a-list-of-geocircles-null-pointer-exception/83297 "2017-04-22T21:31:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MatthewHartz](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@MatthewHartz](https://discuss.elastic.co/u/MatthewHartz)\
**Post date:** [April 22, 2017, 9:31pm UTC](https://discuss.elastic.co/t/elasticsearch-query-if-point-falls-within-a-list-of-geocircles-null-pointer-exception/83297/1 "2017-04-22T21:31:03Z")

</div>

Hi,

I'm trying to determine if a company, which has many locations, services a particular point on the map. I believe i've gotten this query to work once in the past but I can't get it to work currently.

Here is my query, data structure, mapping, and error message. (I've also tried some other queries, but this should be close)

GET corporateoffice/connection/\_search  
{  
"from": 0,  
"size": 20,  
"query": {  
"geo\_shape": {  
"operatinglocations.servicearea": {  
"relation": "within",  
"shape": {  
"type": "circle",  
"coordinates": [  
[  
-117.75,  
33.65  
]  
]  
}  
}  
}  
}  
}

{  
"\_index": "a",  
"\_type": "b",  
"\_source": {  
"id": "22-21",  
"connectionid": 6,  
"operatinglocations": [  
{  
"servicearea": {  
"type": "circle",  
"radius": "50mi",  
"coordinates": [  
-117.7536615,  
33.6599121  
]  
}  
}  
]  
}  
}

{  
"corporateoffice": {  
"mappings": {  
"connection": {  
"properties": {  
"connectionid": {  
"type": "double"  
},  
"id": {  
"type": "string"  
},  
"operatinglocations": {  
"servicearea": {  
"type": "geo\_shape"  
}  
}  
},  
}  
}  
}  
}  
}

{  
"error": {  
"root\_cause": [  
{  
"type": "null\_pointer\_exception",  
"reason": null  
}  
],  
"type": "search\_phase\_execution\_exception",  
"reason": "all shards failed",  
"phase": "query",  
"grouped": true,  
"failed\_shards": [  
{  
"shard": 0,  
"index": "corporateoffice",  
"node": "m8bILPcATemgH1YQ-3-WQA",  
"reason": {  
"type": "null\_pointer\_exception",  
"reason": null  
}  
}  
]  
},  
"status": 500  
}

I tried cleaning up some of the objects too for clarity.. so there may be some json errors if we take it for perfection.

Thanks!

---

<div class="post-metadata">

**Author:** ![MatthewHartz](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@MatthewHartz](https://discuss.elastic.co/u/MatthewHartz)\
**Post date:** [April 22, 2017, 10:00pm UTC](https://discuss.elastic.co/t/elasticsearch-query-if-point-falls-within-a-list-of-geocircles-null-pointer-exception/83297/2 "2017-04-22T22:00:57Z")

</div>

Figured it out.

GET corporateoffice/connection/\_search  
{  
"from": 0,  
"size": 20,  
"query": {  
"geo\_shape": {  
"operatinglocations.servicearea": {  
"relation": "contains",  
"shape": {  
"type": "point",  
"coordinates":  
[  
-120.75,  
33.65  
]  
}  
}  
}  
}  
}

---

<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:** [May 20, 2017, 10:13pm UTC](https://discuss.elastic.co/t/elasticsearch-query-if-point-falls-within-a-list-of-geocircles-null-pointer-exception/83297/3 "2017-05-20T22:13:10Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
