Skip to content

Elasticsearch accepts polygons with disjoint holes #131606

@iverase

Description

@iverase

Elasticsearch might accept illegal polygon that contain polygons with disjoint holes, for example:

POST example/_doc?error_trace=true 
{
  "location": {
    "type": "Polygon",
    "coordinates": [
         [[0, 0], [10, 0], [-0, 10], [0, 0]],
         [[-20, 0], [-19, 0], [-20, 1], [-20, 0]]
    ]
  }
}

In this case, the hole is dropped and it will only index the outer ring. In other cases Elasticsearch will throw a cryptic error message:

POST example/_doc?error_trace=true 
{
  "location": {
    "type": "Polygon",
    "coordinates": [
    [[179, 50], [180, 50], [180, 60], [179, 60], [179, 50]],
    [[-180, 50], [-170, 50], [-170, 60], [-180, 60], [-180.0, 50]]
        
    ]
  }
}

it will throw the following error:

        "type": "illegal_state_exception",
        "reason": "Negative longs unsupported, use writeLong or writeZLong for negative numbers [-4587338432941916160]",
        "stack_trace": """org.elasticsearch.ElasticsearchException$1: Negative longs unsupported, use writeLong or writeZLong for negative numbers [-4587338432941916160]

Elasticsearch should detect those cases and throw a nicer error message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    :Analytics/GeoIndexing, search aggregations of geo points and shapes>bugTeam:AnalyticsMeta label for analytical engine team (ESQL/Aggs/Geo)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions