geo_polygon query over dateline not returning results.
Below is an example dataset and query that demonstrates the problem.
PUT antimeridian
{}
PUT antimeridian/_mapping/_doc
{
"properties": {
"location": {
"type": "geo_point"
}
}
}
PUT antimeridian/_doc/1
{
"location": {
"lat": 0.0,
"lon": 179.5
}
}
PUT antimeridian/_doc/2
{
"location": {
"lat": 0.0,
"lon": -179.5
}
}
PUT antimeridian/_doc/3
{
"location": {
"lat": 0.0,
"lon": 0.0
}
}
# Search with no geo_polygon query returns all 3 documents as expected
GET antimeridian/_search
# Search with geo_polygon that crosses the dateline does not return any documents. Expected 2
documents
# polygon defined as topLeft, bottomLeft, bottomRight, topRight (counter clockwise)
GET antimeridian/_search
{
"query": {
"bool": {
"must": [
{
"geo_polygon": {
"location": {
"points": [
[
-178,
1.5
],
[
178,
1.5
],
[
178,
-1.5
],
[
-178,
-1.5
]
]
}
}
}
]
}
}
}
cc @nknize @iverase
Pinging @elastic/es-analytics-geo
I had a look into the geo_polygon query and indeed it does not support polygons that cross the dateline.
How does one query across the dateline? Does geo bounding box support polygons that cross the dateline?
@nreese geo_bounding_box query does support crossing the dateline.
For geo polygon queries there is no way to query with polygons that crosses the dateline. You would need to break your polygon on the client side (not nice). On the other hand that is actually supported for geo_shape query so I think we should improve it so we can do the same here.
What is the order for geo_bounding_box queries that cross the date line? Would top left be in the eastern hemisphere or the western?
topLeft longitude > bottomRight longitude
"top_left" : {
"lat" : 1.5,
"lon" : 178.0
},
"bottom_right" : {
"lat" : -1.5,
"lon" : -178.0
}
We discussed in the team and this is something we would like to pursue. The idea would be to harmonise the way polygons are built between geo_shape and geo_point
I am closing this issue, the way forward now is to use geo_shape query over geo points.