elastic / elasticsearch

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

Result from Aggregation GeoBounds differ slightly from coordinates #101275

Open superdaminou opened 10 months ago

superdaminou commented 10 months ago

Elasticsearch Version

8.4.1

Installed Plugins

No response

Java Version

bundled

OS Version

Windows 11 Professionnal Version 22H2 22621.2428

Problem Description

While trying to create an aggregation on a geo_point (same for geo_shape of type Point) the geobound aggregation doesn't return the correct value for a single point.

As a user with

When i use the aggregation geo_bounds

Expected:

{
...
"aggregations": {
        "viewport": {
            "bounds": {
                "top_left": {
                    "lat": 10,
                    "lon": 30
                },
                "bottom_right": {
                    "lat": 10,
                    "lon": 30
                }
            }
        }
    }
}

Actual:

{
....
"aggregations": {
        "viewport": {
            "bounds": {
                "top_left": {
                    "lat": 9.999999990686774,
                    "lon": 29.999999972060323
                },
                "bottom_right": {
                    "lat": 9.999999990686774,
                    "lon": 29.999999972060323
                }
            }
        }
    }
  }

Steps to Reproduce

All of this is repoduced with the following docker image: docker.elastic.co/elasticsearch/elasticsearch:8.4.1. Same behaviour with docker.elastic.co/elasticsearch/elasticsearch:8.10.4

  1. Create an index with geo_shape attribute

    curl -XPUT localhost:9200/aggregation_test
    {
    "mappings": {
    "properties": {
      "location": {
        "type": "geo_point"
      }
    }
    }
  2. Insert a single POINT with simple coordinates

    curl -XPUT localhost:9200/aggregation_test/_doc/1
    {
    "location" : {
    "type" : "Point",
    "coordinates" : 
      [30.0, 10.0 ]
    }
    }
  3. Trying to aggregate with geo_bounds

    curl -XPOST localhost:9200/aggregation_test/_search?size=0
    {
    "aggs": {
    "viewport": {
      "geo_bounds": {
        "field": "location"
      }
    }
    }
    }

Logs (if relevant)

No response

elasticsearchmachine commented 10 months ago

Pinging @elastic/es-analytics-geo (Team:Analytics)

iverase commented 1 month ago

This is actually expected and somewhat documented here https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-bounding-box-query.html#_notes_on_precision. I think the only action to take here is to improve documentation so I will relabel this issue to docs.

elasticsearchmachine commented 1 month ago

Pinging @elastic/es-docs (Team:Docs)

elasticsearchmachine commented 1 month ago

Pinging @elastic/es-analytical-engine (Team:Analytics)