-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Labels
:Analytics/GeoIndexing, search aggregations of geo points and shapesIndexing, search aggregations of geo points and shapes>bugstalled
Description
In ES 2.4.x the following script shows a bug where for a certain polygon the geo polygon query matches points outside the polygon.
Gist showing polygon in blue, bounding box in red outline and indexed point from script: https://gist.github.com/anonymous/c330a7bc64f8b52add1dc43698c38dbe
DELETE test
#Set up an index with a geo_point field
PUT test
{
"settings": {
"number_of_replicas": 0,
"number_of_shards": 1
},
"mappings": {
"doc": {
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
}
# Index a document containing a point outside the polygon we are going to using in our search
POST test/doc/1
{
"location": {
"lat": 52.08063,
"lon": 0.02002
}
}
# This geo_polygon query returns 1 hit even though the document is outside the polygon (gist showing polygon in blue: https://gist.github.com/anonymous/9e404e940e4b39060ec88c2fd9895914):
GET test/doc/_search
{
"size": 1,
"query": {
"geo_polygon": {
"location": {
"points": [
[
-0.016550000000000002,
51.60118000000001
],
[
-0.01157,
51.60049000000001
],
[
-0.00151,
51.60052
],
[
-0.0009500000000000001,
51.60096000000001
],
[
0.00002,
51.60137
],
[
0.00048000000000000007,
51.601760000000006
],
[
0.00108,
51.60217
],
[
0.0016500000000000002,
51.60253
],
[
0.00198,
51.60295000000001
],
[
0.00218,
51.603350000000006
],
[
0.0027,
51.60367
],
[
0.00265,
51.604110000000006
],
[
0.00249,
51.60474000000001
],
[
0.00205,
51.605540000000005
],
[
0.0018900000000000002,
51.605940000000004
],
[
0.0036100000000000004,
51.60624000000001
],
[
0.004240000000000001,
51.6064
],
[
0.004880000000000001,
51.606640000000006
],
[
0.005600000000000001,
51.606840000000005
],
[
0.0074600000000000005,
51.60802
],
[
0.01003,
51.608700000000006
],
[
0.01071,
51.61717
],
[
0.009680000000000001,
51.618080000000006
],
[
0.00864,
51.61883
],
[
0.0032500000000000003,
51.61547
],
[
0,
51.61536
],
[
-0.0023000000000000004,
51.61813
],
[
-0.017320000000000002,
51.61686
],
[
-0.01786,
51.60976
],
[
-0.016550000000000002,
51.60118000000001
]
]
}
}
}
}
# geo_polygon query on the bounding box of the polygon correctly returns 0 hits:
GET test/doc/_search
{
"size": 1,
"query": {
"geo_polygon": {
"location": {
"points": [
[
-0.01786116510629654,
51.60048899240792
],
[
0.010710898786783218,
51.60048899240792
],
[
0.010710898786783218,
51.618830943480134
],
[
-0.01786116510629654,
51.618830943480134
],
[
-0.01786116510629654,
51.60048899240792
]
]
}
}
}
}
# geo_polygon query on polygon with two points on north side removed correctly returns 0 hits (gist showing polygon in blue: https://gist.github.com/anonymous/9d91a776b998b085e83d4c81b4375831):
GET test/doc/_search
{
"size": 1,
"query": {
"geo_polygon": {
"location": {
"points": [
[
-0.016550000000000002,
51.60118000000001
],
[
-0.01157,
51.60049000000001
],
[
-0.00151,
51.60052
],
[
-0.0009500000000000001,
51.60096000000001
],
[
0.00002,
51.60137
],
[
0.00048000000000000007,
51.601760000000006
],
[
0.00108,
51.60217
],
[
0.0016500000000000002,
51.60253
],
[
0.00198,
51.60295000000001
],
[
0.00218,
51.603350000000006
],
[
0.0027,
51.60367
],
[
0.00265,
51.604110000000006
],
[
0.00249,
51.60474000000001
],
[
0.00205,
51.605540000000005
],
[
0.0018900000000000002,
51.605940000000004
],
[
0.0036100000000000004,
51.60624000000001
],
[
0.004240000000000001,
51.6064
],
[
0.004880000000000001,
51.606640000000006
],
[
0.005600000000000001,
51.606840000000005
],
[
0.0074600000000000005,
51.60802
],
[
0.01003,
51.608700000000006
],
[
0.01071,
51.61717
],
[
0.009680000000000001,
51.618080000000006
],
[
-0.0023000000000000004,
51.61813
],
[
-0.017320000000000002,
51.61686
],
[
-0.01786,
51.60976
],
[
-0.016550000000000002,
51.60118000000001
]
]
}
}
}
}
Metadata
Metadata
Assignees
Labels
:Analytics/GeoIndexing, search aggregations of geo points and shapesIndexing, search aggregations of geo points and shapes>bugstalled