# Incorrect results from geo\_shape filter

**URL:** <https://discuss.elastic.co/t/incorrect-results-from-geo-shape-filter/22278>\
**Category:** Elasticsearch\
**Created:** [February 19, 2015, 11:04pm UTC](https://discuss.elastic.co/t/incorrect-results-from-geo-shape-filter/22278 "2015-02-19T23:04:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexei\_Peters](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexei_peters/32/898_2.png) [@Alexei\_Peters](https://discuss.elastic.co/u/Alexei_Peters)\
**Post date:** [February 19, 2015, 11:04pm UTC](https://discuss.elastic.co/t/incorrect-results-from-geo-shape-filter/22278/1 "2015-02-19T23:04:29Z")

</div>

Hey Everyone,

I have a nested document that includes a spatial component that I'm using  
in a spatial query via the geo\_shape filter.  
I've noticed that the filter consistently returns a result that includes a  
geometry that clearly falls outside the spatial filter.  
I've tested the spatial intersection in PostGIS and that correctly returns  
back no result from the same query.

Can anyone else verify this? We have lots of other MultiPolygon data that  
seems to work just fine.

I'm using the REST api against ES v1.4.1

_Here's the document I'm testing against:_

{"dates": [],  
"geometries": [{  
"value": {  
"type": "MultiPolygon",  
"coordinates": [  
[  
[  
[-118.32608,  
34.07035],  
[-118.32657,  
34.07035],  
[-118.32657,  
34.07054],  
[-118.32608,  
34.07054],  
[-118.32608,  
34.07035]  
]  
],  
[  
[  
[-118.32608,  
34.07021],  
[-118.32608,  
34.07004],  
[-118.32657,  
34.07004],  
[-118.32657,  
34.07021],  
[-118.32608,  
34.07021]  
]  
]  
]  
},  
"label": "MULTIPOLYGON (((-118.32608 34.07035,-118.32657  
34.07035,-118.32657 34.07054,-118.32608 34.07054,-118.32608  
34.07035)),((-118.32608 34.07021,-118.32608 34.07004,-118.32657  
34.07004,-118.32657 34.07021,-118.32608 34.07021)))",  
"child\_entities": [],  
"entitytypeid": "SPATIAL\_COORDINATES\_GEOMETRY.E47",  
"parentid": "80446382-0e96-4db1-8a37-95aca166b785",  
"entityid": "81b06621-2989-4825-98f3-88ee2ac937b6",  
"property": "P87",  
"businesstablename": "geometries"  
}],  
"child\_entities": [{  
"value": "Windsor Square District Non-Contributor",  
"label": "Windsor Square District Non-Contributor",  
"child\_entities": [],  
"entitytypeid": "NAME.E41",  
"parentid": "5fbe787f-8fc3-4986-b77a-38828699b68c",  
"entityid": "62a82362-b7c3-4ad2-ba58-29bab7dc5dbb",  
"property": "P1",  
"businesstablename": "strings"  
}, {  
"value": "",  
"label": "",  
"child\_entities": [],  
"entitytypeid": "PLACE.E53",  
"parentid": "5fbe787f-8fc3-4986-b77a-38828699b68c",  
"entityid": "80446382-0e96-4db1-8a37-95aca166b785",  
"property": "P53",  
"businesstablename": ""  
}],  
"label": "",  
"date\_groups": [],  
"primaryname": "Windsor Square District Non-Contributor",  
"value": "",  
"entitytypeid": "HERITAGE\_RESOURCE.E18",  
"domains": [{  
"conceptid": "a5675b84-fed4-4839-9afa-434be64c3899",  
"child\_entities": [],  
"label": "Primary",  
"value": "b171b37b-4c78-4b51-91a9-503541511be4",  
"entitytypeid": "NAME\_TYPE.E55",  
"parentid": "62a82362-b7c3-4ad2-ba58-29bab7dc5dbb",  
"entityid": "4bd86b01-a047-4e7a-953a-00d2243e39db",  
"property": "P2",  
"businesstablename": "domains"  
}],  
"entityid": "5fbe787f-8fc3-4986-b77a-38828699b68c",  
"property": "",  
"businesstablename": ""}

_Here's the DSL:_

{  
"query": {  
"filtered": {  
"filter": {  
"and": [  
{  
"bool": {  
"should": [],  
"must\_not": [],  
"must": [  
{  
"nested": {  
"path": "geometries",  
"query": {  
"geo\_shape": {  
"geometries.value": {  
"shape": {  
"type": "Point",  
"coordinates": [  
-118.34194465228431,  
34.06402964781424  
]  
}  
}  
}  
}  
}  
}  
]  
}  
}  
]  
},  
"query": {  
"match\_all": {}  
}  
}  
},  
"from": 0,  
"size": 5  
}

_Here's the mapping for the index:_

"properties": {  
"businesstablename": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"child\_entities": {  
"type": "nested",  
"properties": {  
"businesstablename": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"entitytypeid": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"property": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"entityid": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"label": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"value": {  
"type": "string",  
"fields": {  
"raw": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"folded": {  
"analyzer": "folding",  
"type": "string"  
}  
}  
},  
"parentid": {  
"index": "not\_analyzed",  
"type": "string"  
}  
}  
},  
"entitytypeid": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"domains": {  
"type": "nested",  
"properties": {  
"businesstablename": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"entitytypeid": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"property": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"conceptid": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"entityid": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"label": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"value": {  
"type": "string",  
"fields": {  
"raw": {  
"index": "not\_analyzed",  
"type": "string"  
}  
}  
},  
"parentid": {  
"index": "not\_analyzed",  
"type": "string"  
}  
}  
},  
"dates": {  
"type": "nested",  
"properties": {  
"businesstablename": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"entitytypeid": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"property": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"entityid": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"label": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"value": {  
"format": "dateOptionalTime",  
"type": "date"  
},  
"parentid": {  
"index": "not\_analyzed",  
"type": "string"  
}  
}  
},  
"entityid": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"label": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"parentid": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"date\_groups": {  
"properties": {  
"conceptid": {  
"index": "not\_analyzed",  
"type": "string"  
}  
}  
},  
"geometries": {  
"type": "nested",  
"properties": {  
"businesstablename": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"entitytypeid": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"property": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"entityid": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"label": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"value": {  
"type": "geo\_shape"  
},  
"parentid": {  
"index": "not\_analyzed",  
"type": "string"  
}  
}  
},  
"primaryname": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"property": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"value": {  
"index": "not\_analyzed",  
"type": "string"  
}  
}

Cheers,  
Alexei

--  
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/76350f1a-8ff6-4aba-a964-a4ddaf59a123%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/76350f1a-8ff6-4aba-a964-a4ddaf59a123%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Alexei\_Peters](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexei_peters/32/898_2.png) [@Alexei\_Peters](https://discuss.elastic.co/u/Alexei_Peters)\
**Post date:** [February 19, 2015, 11:11pm UTC](https://discuss.elastic.co/t/incorrect-results-from-geo-shape-filter/22278/2 "2015-02-19T23:11:40Z")

</div>

FYI, you can also try a search using these coordinates (which are clearly  
incorrect) in your filter, and it still returns a result.

"coordinates": [-119, 35]

On Thursday, February 19, 2015 at 3:04:29 PM UTC-8, Alexei Peters wrote:

> Hey Everyone,
> 
> I have a nested document that includes a spatial component that I'm using  
> in a spatial query via the geo\_shape filter.  
> I've noticed that the filter consistently returns a result that includes a  
> geometry that clearly falls outside the spatial filter.  
> I've tested the spatial intersection in PostGIS and that correctly returns  
> back no result from the same query.
> 
> Can anyone else verify this? We have lots of other MultiPolygon data that  
> seems to work just fine.
> 
> I'm using the REST api against ES v1.4.1
> 
> _Here's the document I'm testing against:_
> 
> {"dates": ,  
> "geometries": [{  
> "value": {  
> "type": "MultiPolygon",  
> "coordinates": [  
> [  
> [  
> [-118.32608,  
> 34.07035],  
> [-118.32657,  
> 34.07035],  
> [-118.32657,  
> 34.07054],  
> [-118.32608,  
> 34.07054],  
> [-118.32608,  
> 34.07035]  
> ]  
> ],  
> [  
> [  
> [-118.32608,  
> 34.07021],  
> [-118.32608,  
> 34.07004],  
> [-118.32657,  
> 34.07004],  
> [-118.32657,  
> 34.07021],  
> [-118.32608,  
> 34.07021]  
> ]  
> ]  
> ]  
> },  
> "label": "MULTIPOLYGON (((-118.32608 34.07035,-118.32657  
> 34.07035,-118.32657 34.07054,-118.32608 34.07054,-118.32608  
> 34.07035)),((-118.32608 34.07021,-118.32608 34.07004,-118.32657  
> 34.07004,-118.32657 34.07021,-118.32608 34.07021)))",  
> "child\_entities": ,  
> "entitytypeid": "SPATIAL\_COORDINATES\_GEOMETRY.E47",  
> "parentid": "80446382-0e96-4db1-8a37-95aca166b785",  
> "entityid": "81b06621-2989-4825-98f3-88ee2ac937b6",  
> "property": "P87",  
> "businesstablename": "geometries"  
> }],  
> "child\_entities": [{  
> "value": "Windsor Square District Non-Contributor",  
> "label": "Windsor Square District Non-Contributor",  
> "child\_entities": ,  
> "entitytypeid": "NAME.E41",  
> "parentid": "5fbe787f-8fc3-4986-b77a-38828699b68c",  
> "entityid": "62a82362-b7c3-4ad2-ba58-29bab7dc5dbb",  
> "property": "P1",  
> "businesstablename": "strings"  
> }, {  
> "value": "",  
> "label": "",  
> "child\_entities": ,  
> "entitytypeid": "PLACE.E53",  
> "parentid": "5fbe787f-8fc3-4986-b77a-38828699b68c",  
> "entityid": "80446382-0e96-4db1-8a37-95aca166b785",  
> "property": "P53",  
> "businesstablename": ""  
> }],  
> "label": "",  
> "date\_groups": ,  
> "primaryname": "Windsor Square District Non-Contributor",  
> "value": "",  
> "entitytypeid": "HERITAGE\_RESOURCE.E18",  
> "domains": [{  
> "conceptid": "a5675b84-fed4-4839-9afa-434be64c3899",  
> "child\_entities": ,  
> "label": "Primary",  
> "value": "b171b37b-4c78-4b51-91a9-503541511be4",  
> "entitytypeid": "NAME\_TYPE.E55",  
> "parentid": "62a82362-b7c3-4ad2-ba58-29bab7dc5dbb",  
> "entityid": "4bd86b01-a047-4e7a-953a-00d2243e39db",  
> "property": "P2",  
> "businesstablename": "domains"  
> }],  
> "entityid": "5fbe787f-8fc3-4986-b77a-38828699b68c",  
> "property": "",  
> "businesstablename": ""}
> 
> _Here's the DSL:_
> 
> {  
> "query": {  
> "filtered": {  
> "filter": {  
> "and": [  
> {  
> "bool": {  
> "should": ,  
> "must\_not": ,  
> "must": [  
> {  
> "nested": {  
> "path": "geometries",  
> "query": {  
> "geo\_shape": {  
> "geometries.value": {  
> "shape": {  
> "type": "Point",  
> "coordinates": [  
> -118.34194465228431,  
> 34.06402964781424  
> ]  
> }  
> }  
> }  
> }  
> }  
> }  
> ]  
> }  
> }  
> ]  
> },  
> "query": {  
> "match\_all": {}  
> }  
> }  
> },  
> "from": 0,  
> "size": 5  
> }
> 
> _Here's the mapping for the index:_
> 
> "properties": {  
> "businesstablename": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "child\_entities": {  
> "type": "nested",  
> "properties": {  
> "businesstablename": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "entitytypeid": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "property": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "entityid": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "label": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "value": {  
> "type": "string",  
> "fields": {  
> "raw": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "folded": {  
> "analyzer": "folding",  
> "type": "string"  
> }  
> }  
> },  
> "parentid": {  
> "index": "not\_analyzed",  
> "type": "string"  
> }  
> }  
> },  
> "entitytypeid": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "domains": {  
> "type": "nested",  
> "properties": {  
> "businesstablename": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "entitytypeid": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "property": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "conceptid": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "entityid": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "label": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "value": {  
> "type": "string",  
> "fields": {  
> "raw": {  
> "index": "not\_analyzed",  
> "type": "string"  
> }  
> }  
> },  
> "parentid": {  
> "index": "not\_analyzed",  
> "type": "string"  
> }  
> }  
> },  
> "dates": {  
> "type": "nested",  
> "properties": {  
> "businesstablename": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "entitytypeid": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "property": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "entityid": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "label": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "value": {  
> "format": "dateOptionalTime",  
> "type": "date"  
> },  
> "parentid": {  
> "index": "not\_analyzed",  
> "type": "string"  
> }  
> }  
> },  
> "entityid": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "label": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "parentid": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "date\_groups": {  
> "properties": {  
> "conceptid": {  
> "index": "not\_analyzed",  
> "type": "string"  
> }  
> }  
> },  
> "geometries": {  
> "type": "nested",  
> "properties": {  
> "businesstablename": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "entitytypeid": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "property": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "entityid": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "label": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "value": {  
> "type": "geo\_shape"  
> },  
> "parentid": {  
> "index": "not\_analyzed",  
> "type": "string"  
> }  
> }  
> },  
> "primaryname": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "property": {  
> "index": "not\_analyzed",  
> "type": "string"  
> },  
> "value": {  
> "index": "not\_analyzed",  
> "type": "string"  
> }  
> }
> 
> Cheers,  
> Alexei

--  
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/04543e87-89ad-4b1c-803a-0210c0c1b727%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/04543e87-89ad-4b1c-803a-0210c0c1b727%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:31am UTC](https://discuss.elastic.co/t/incorrect-results-from-geo-shape-filter/22278/3 "2017-07-06T00:31:22Z")

</div>


