# False positive results for spatial search

**URL:** https://discuss.elastic.co/t/false-positive-results-for-spatial-search/21718
**Category:** Elasticsearch
**Created:** [January 19, 2015, 8:02pm UTC](https://discuss.elastic.co/t/false-positive-results-for-spatial-search/21718 "2015-01-19T20:02:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Lukasz\_Smoron](https://avatars.discourse-cdn.com/v4/letter/l/9dc877/32.png) [@Lukasz\_Smoron](https://discuss.elastic.co/u/Lukasz_Smoron)
#### Post date: [January 19, 2015, 8:02pm UTC](https://discuss.elastic.co/t/false-positive-results-for-spatial-search/21718/1 "2015-01-19T20:02:08Z")

</div>

hi,

I got simple spatial field:  
PRIMARY\_GEOMETRY: {  
type: "geo\_shape"  
}

I index following geometry  
{"PRIMARY\_GEOMETRY":  
{"geometries":[  
{"coordinates":[[[-87.6544,41.9677],[-87.6544,41.9717],[-87.6489,41.9717],[-87.6489,41.9677],[-87.6544,41.9677]]],"type":"Polygon"},  
{"coordinates":[[[-87.6544,41.9472],[-87.6544,41.9513],[-87.6489,41.9513],[-87.6489,41.9472],[-87.6544,41.9472]]],"type":"Polygon"}  
],"type":"GeometryCollection"}  
}

and then I try to search with following query

{"query":{"filtered":{"query":{"geo\_shape":{"PRIMARY\_GEOMETRY":{"shape":{"coordinates":[[[-87.8826,41.6908],[-87.9127,41.7161],[-87.9382,41.7441],[-87.959,41.7743],[-87.9745,41.8062],[-87.9845,41.8392],[-87.989,41.873],[-87.9878,41.9069],[-87.9808,41.9404],[-87.9683,41.973],[-87.9505,42.0042],[-87.9274,42.0335],[-87.8997,42.0603],[-87.8676,42.0844],[-87.8317,42.1053],[-87.7925,42.1226],[-87.7507,42.1361],[-87.707,42.1456],[-87.662,42.1509],[-87.6164,42.152],[-87.571,42.1488],[-87.5266,42.1414],[-87.4837,42.1298],[-87.4431,42.1144],[-87.4055,42.0952],[-87.3715,42.0727],[-87.3415,42.0472],[-87.316,42.0191],[-87.2955,41.9888],[-87.2803,41.9569],[-87.2706,41.9237],[-87.2665,41.89],[-87.2681,41.8561],[-87.2754,41.8226],[-87.2882,41.79],[-87.3064,41.759],[-87.3296,41.7298],[-87.3574,41.7031],[-87.3895,41.6792],[-87.4254,41.6585],[-87.4643,41.6413],[-87.5059,41.6278],[-87.5493,41.6184],[-87.5939,41.6131],[-87.6391,41.6121],[-87.6841,41.6153],[-87.7282,41.6226],[-87.7708,41.6341],[-87.8111,41.6494],[-87.8486,41.6684],[-87.8826,41.6908]],[[-87.8818,41.6914],[-87.9117,41.7167],[-87.9372,41.7446],[-87.9578,41.7747],[-87.9733,41.8064],[-87.9834,41.8394],[-87.9878,41.873],[-87.9866,41.9068],[-87.9797,41.9402],[-87.9672,41.9727],[-87.9494,42.0038],[-87.9264,42.033],[-87.8988,42.0597],[-87.8668,42.0837],[-87.831,42.1045],[-87.792,42.1218],[-87.7503,42.1353],[-87.7067,42.1447],[-87.6618,42.15],[-87.6164,42.1511],[-87.5712,42.1479],[-87.5269,42.1405],[-87.4842,42.129],[-87.4438,42.1136],[-87.4063,42.0945],[-87.3723,42.0721],[-87.3424,42.0467],[-87.3171,42.0187],[-87.2967,41.9885],[-87.2815,41.9566],[-87.2718,41.9236],[-87.2677,41.8899],[-87.2693,41.8561],[-87.2766,41.8228],[-87.2894,41.7904],[-87.3074,41.7594],[-87.3306,41.7303],[-87.3583,41.7037],[-87.3903,41.6799],[-87.426,41.6592],[-87.4649,41.6421],[-87.5063,41.6287],[-87.5495,41.6193],[-87.594,41.614],[-87.6391,41.613],[-87.6839,41.6161],[-87.7279,41.6235],[-87.7703,41.6349],[-87.8105,41.6502],[-87.8479,41.6691],[-87.8818,41.6914]]],"type":"Polygon"}}}}}}}

[https://lh3.googleusercontent.com/-akprdJOvsRM/VL1iIrXnTyI/AAAAAAAAEo4/C2ZC1OdZQz4/s1600/Screen%2BShot%2B2015-01-19%2Bat%2B1.58.30%2BPM.png](https://lh3.googleusercontent.com/-akprdJOvsRM/VL1iIrXnTyI/AAAAAAAAEo4/C2ZC1OdZQz4/s1600/Screen%2BShot%2B2015-01-19%2Bat%2B1.58.30%2BPM.png)  
This query returns previously indexed polygons. The problem is that I am  
querying for shapes interacting with thin ring and those two shapes should  
not be interacting with it.

What could I be doing wrong here?

Thanks  
Luke

--  
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/8fabeb5e-eead-4d44-bf0a-74358841177a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8fabeb5e-eead-4d44-bf0a-74358841177a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)
#### Post date: [January 20, 2015, 9:32am UTC](https://discuss.elastic.co/t/false-positive-results-for-spatial-search/21718/2 "2015-01-20T09:32:17Z")

</div>

HI Luke,

This looks like a bug in the geo\_shape query. I have raised the following  
issue in the Elasticsearch repo:

> <https://github.com/elastic/elasticsearch/issues/9360>
>
> See the gist at \[1\] for a visual example of the polygons involved and a script …to reproduce the bug. The bug occurs when you index a document containing two simple polygons and then query for shape which intersect a polygon representing a ring around (but not touching) the two indexed shapes. The query returns the document when it shouldn't since neither of the shapes interact with the ring.
> 
> Changing the \`relation\` option to either \`within\` or \`disjoint\` produce no results from the query.
> 
> \[1\] https://gist.github.com/colings86/0a0184ba79c5367685ff
> 
> This bug was raised from the following mailing list post: https://groups.google.com/forum/#!topic/elasticsearch/TlqaVu91R7A

Thanks for raising this.

Colin

On Monday, 19 January 2015 20:02:08 UTC, Lukasz Smoron wrote:

> hi,
> 
> I got simple spatial field:  
> PRIMARY\_GEOMETRY: {  
> type: "geo\_shape"  
> }
> 
> I index following geometry  
> {"PRIMARY\_GEOMETRY":  
> {"geometries":[
> 
> {"coordinates":[[[-87.6544,41.9677],[-87.6544,41.9717],[-87.6489,41.9717],[-87.6489,41.9677],[-87.6544,41.9677]]],"type":"Polygon"},
> 
> {"coordinates":[[[-87.6544,41.9472],[-87.6544,41.9513],[-87.6489,41.9513],[-87.6489,41.9472],[-87.6544,41.9472]]],"type":"Polygon"}  
> ],"type":"GeometryCollection"}  
> }
> 
> and then I try to search with following query
> 
> {"query":{"filtered":{"query":{"geo\_shape":{"PRIMARY\_GEOMETRY":{"shape":{"coordinates":[[[-87.8826,41.6908],[-87.9127,41.7161],[-87.9382,41.7441],[-87.959,41.7743],[-87.9745,41.8062],[-87.9845,41.8392],[-87.989,41.873],[-87.9878,41.9069],[-87.9808,41.9404],[-87.9683,41.973],[-87.9505,42.0042],[-87.9274,42.0335],[-87.8997,42.0603],[-87.8676,42.0844],[-87.8317,42.1053],[-87.7925,42.1226],[-87.7507,42.1361],[-87.707,42.1456],[-87.662,42.1509],[-87.6164,42.152],[-87.571,42.1488],[-87.5266,42.1414],[-87.4837,42.1298],[-87.4431,42.1144],[-87.4055,42.0952],[-87.3715,42.0727],[-87.3415,42.0472],[-87.316,42.0191],[-87.2955,41.9888],[-87.2803,41.9569],[-87.2706,41.9237],[-87.2665,41.89],[-87.2681,41.8561],[-87.2754,41.8226],[-87.2882,41.79],[-87.3064,41.759],[-87.3296,41.7298],[-87.3574,41.7031],[-87.3895,41.6792],[-87.4254,41.6585],[-87.4643,41.6413],[-87.5059,41.6278],[-87.5493,41.6184],[-87.5939,41.6131],[-87.6391,41.6121],[-87.6841,41.6153],[-87.7282,41.6226],[-87.7708,41.6341],[-87.8111,41.6494],[-87.8486,41.6684],[-87.8826,41.6908]],[[-87.8818,41.6914],[-87.9117,41.7167],[-87.9372,41.7446],[-87.9578,41.7747],[-87.9733,41.8064],[-87.9834,41.8394],[-87.9878,41.873],[-87.9866,41.9068],[-87.9797,41.9402],[-87.9672,41.9727],[-87.9494,42.0038],[-87.9264,42.033],[-87.8988,42.0597],[-87.8668,42.0837],[-87.831,42.1045],[-87.792,42.1218],[-87.7503,42.1353],[-87.7067,42.1447],[-87.6618,42.15],[-87.6164,42.1511],[-87.5712,42.1479],[-87.5269,42.1405],[-87.4842,42.129],[-87.4438,42.1136],[-87.4063,42.0945],[-87.3723,42.0721],[-87.3424,42.0467],[-87.3171,42.0187],[-87.2967,41.9885],[-87.2815,41.9566],[-87.2718,41.9236],[-87.2677,41.8899],[-87.2693,41.8561],[-87.2766,41.8228],[-87.2894,41.7904],[-87.3074,41.7594],[-87.3306,41.7303],[-87.3583,41.7037],[-87.3903,41.6799],[-87.426,41.6592],[-87.4649,41.6421],[-87.5063,41.6287],[-87.5495,41.6193],[-87.594,41.614],[-87.6391,41.613],[-87.6839,41.6161],[-87.7279,41.6235],[-87.7703,41.6349],[-87.8105,41.6502],[-87.8479,41.6691],[-87.8818,41.6914]]],"type":"Polygon"}}}}}}}
> 
> [https://lh3.googleusercontent.com/-akprdJOvsRM/VL1iIrXnTyI/AAAAAAAAEo4/C2ZC1OdZQz4/s1600/Screen%2BShot%2B2015-01-19%2Bat%2B1.58.30%2BPM.png](https://lh3.googleusercontent.com/-akprdJOvsRM/VL1iIrXnTyI/AAAAAAAAEo4/C2ZC1OdZQz4/s1600/Screen%2BShot%2B2015-01-19%2Bat%2B1.58.30%2BPM.png)  
> This query returns previously indexed polygons. The problem is that I am  
> querying for shapes interacting with thin ring and those two shapes should  
> not be interacting with it.
> 
> What could I be doing wrong here?
> 
> Thanks  
> Luke

--  
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/186e5f9e-7512-400c-bfcc-88b572a11e2c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/186e5f9e-7512-400c-bfcc-88b572a11e2c%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:37am UTC](https://discuss.elastic.co/t/false-positive-results-for-spatial-search/21718/3 "2017-07-06T00:37:49Z")

</div>


