# Looking for a point within a geo\_shape

**URL:** https://discuss.elastic.co/t/looking-for-a-point-within-a-geo-shape/44700
**Category:** Elasticsearch
**Created:** [March 17, 2016, 11:10am UTC](https://discuss.elastic.co/t/looking-for-a-point-within-a-geo-shape/44700 "2016-03-17T11:10:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![alexshires](https://avatars.discourse-cdn.com/v4/letter/a/3e96dc/32.png) [@alexshires](https://discuss.elastic.co/u/alexshires)
#### Post date: [March 17, 2016, 11:10am UTC](https://discuss.elastic.co/t/looking-for-a-point-within-a-geo-shape/44700/1 "2016-03-17T11:10:07Z")

</div>

Hi all,

I'm trying to correctly format a query that returns a polygon geo\_shape given a point geo\_shape.

My mapping is

> "outputarea-index" : {  
> "aliases" : { },  
> "mappings" : {  
> "outputarea" : {  
> "properties" : {  
> "location" : {  
> "type" : "geo\_shape",  
> "tree" : "quadtree",  
> "precision" : "10.0m"  
> },  
> "oa\_id" : {  
> "type" : "string"  
> }  
> }  
> }  
> },

and my document is

> "type": "Feature", "properties": { "OA11CD": "E00000001", "LAD11CD": "E09000001" }, "geometry": { "type": "Polygon", "coordinates": [[ [ -0.094486180992449, 51.520329824877336], [-0.094515616052987, 51.52023932543856], [-0.094539915144025, 51.520164470526943], [-0.094544324018805, 51.52015070261556], [-0.094573093007717, 51.520060614990577], [-0.094615644263065, 51.519921085391069], [-0.094621105045769, 51.519903180006096], [-0.094632294581515, 51.519882705887319], [-0.094643015216892, 51.519863105420363], [-0.094647432986907, 51.519854993963698], [-0.09453051769114, 51.519828787812926], [-0.09447184960877, 51.519809849605494], [-0.094504707419636, 51.519759242770952], [-0.094536816899835, 51.519766967440994], [-0.094713504727674, 51.519809476840926], [-0.095790721630945, 51.520068626885028], [-0.096121025721161, 51.520148096396902], [-0.096088566098825, 51.520210274553293], [-0.09599411910667, 51.520223857913599], [-0.096014162391047, 51.520262734328782], [-0.096046381877994, 51.520325207001612], [-0.096220261861897, 51.520293417056905], [-0.0965101097006, 51.520240425029648], [-0.096510142797268, 51.520240668365567], [-0.096515641941531, 51.520274371752606], [-0.096329725955979, 51.520308934330373], [-0.096313949525538, 51.520311870631495], [-0.095956238129518, 51.520377995755709], [-0.095800108757507, 51.520406161727557], [-0.09567888031131, 51.520428014835232], [-0.095613131457773, 51.520439878630029], [-0.095440650073645, 51.520470944007648], [-0.095356224874306, 51.520486146380406], [-0.095269034239812, 51.520501987218282], [-0.095266187305836, 51.520502507517243], [-0.095234378645064, 51.520508285753003], [-0.095079358314049, 51.520536450794644], [-0.09477056340925, 51.520594347219664], [-0.094752475812971, 51.520597740360863], [-0.094389398782176, 51.520662802375568], [-0.094396489284427, 51.520638664664645], [-0.094400152058549, 51.520626197549888], [-0.094414604769778, 51.520576937359905], [-0.094452530601296, 51.520445336047963], [-0.094486180992449, 51.520329824877336] ] ] } },  
> { "type": "Feature", "properties": { "OA11CD": "E00000003", "LAD11CD": "E09000001" }, "geometry": { "type": "Polygon", "coordinates": [[ [ -0.09599411910667, 51.520223857913599], [-0.096088566098825, 51.520210274553293], [-0.096121025721161, 51.520148096396902], [-0.095790721630945, 51.520068626885028], [-0.095787404084913, 51.519949116003055], [-0.095935455687077, 51.519982912476515], [-0.095948489714641, 51.519922694133861], [-0.095960685226705, 51.519925778715645], [-0.095994561397434, 51.519870071244611], [-0.096031453986505, 51.519809430856192], [-0.096065700798209, 51.519753126880339], [-0.09606901233941, 51.519747686186967], [-0.096088684391019, 51.519712511917589], [-0.096130457625741, 51.519637832419292], [-0.096171763736963, 51.519563981631016], [-0.09618933251572, 51.519532577053752], [-0.096193631160026, 51.519524895249006], [-0.096225423482185, 51.519453470881587], [-0.096271634413594, 51.519382280530003], [-0.096300796986486, 51.519328978409156], [-0.096317008127682, 51.519338422914892], [-0.096529725592892, 51.519462303406655], [-0.096546961585842, 51.519575772332189], [-0.096548951955675, 51.519588879798469], [-0.096594147585317, 51.519674439949107], [-0.096607392601375, 51.519688998002039], [-0.096630847446302, 51.519714854509601], [-0.096633714301697, 51.519718003460909], [-0.097047718674619, 51.51967925468022], [-0.096512638401641, 51.520152815701181], [-0.09650754975382, 51.520157319319381], [-0.096496809821867, 51.520159078423092], [-0.096497970745168, 51.520165805704146], [-0.0965101097006, 51.520240425029648], [-0.096220261861897, 51.520293417056905], [-0.096046381877994, 51.520325207001612], [-0.096014162391047, 51.520262734328782], [-0.09599411910667, 51.520223857913599] ] ] } },

and the query is

> 'query': {'bool': {'filter': {'geo\_shape': {'location': {'shape': {'type': 'point', 'coordinates': [-0.096786, 51.517569]}, 'relation': 'contains'}}}, 'must': {'match\_all': {}}}}, 'size': 10}

with the result:

> TransportError(400, u'search\_phase\_execution\_exception', u'')

any ideas?

---

<div class="post-metadata">

### Author: ![rickyhiga](https://avatars.discourse-cdn.com/v4/letter/r/9dc877/32.png) [@rickyhiga](https://discuss.elastic.co/u/rickyhiga)
#### Post date: [June 18, 2016, 4:42am UTC](https://discuss.elastic.co/t/looking-for-a-point-within-a-geo-shape/44700/2 "2016-06-18T04:42:36Z")

</div>

Hi! have you tried changing 'relation': 'contains' to 'relation': 'intersects'?

---

<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 5, 2017, 10:42pm UTC](https://discuss.elastic.co/t/looking-for-a-point-within-a-geo-shape/44700/3 "2017-07-05T22:42:34Z")

</div>


