elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.6k stars 24.63k forks source link

geo_shape query matches shapes inside hole of complex polygon #9360

Closed colings86 closed 9 years ago

colings86 commented 9 years ago

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

colings86 commented 9 years ago

@nknize are you able to take a look at this?

nknize commented 9 years ago

Thanks for reporting this, there appears to be a legit bug in Lucene-Spatial's IntersectsPrefixTreeFilter. Will take a look and get a patch out ASAP.

lsmoron commented 9 years ago

I did one more test - checking if right/left hand rule impact this. After indexing following geometries both of them showed in results for that query

{"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.9677],[-87.6489,41.9677],[-87.6489,41.9717],[-87.6544,41.9717],[-87.6544,41.9677]]],"type":"Polygon"}