Skip to content

WKT polygon format validated with geo_shape, where coerce set to true #35059

@artemabalmasov

Description

@artemabalmasov

Good day, trying to integrate twitter location data in WKT format, run into following issue:

System

version: 
{
  "name": "3w66Vhm",
  "cluster_name": "docker-cluster",
  "cluster_uuid": "9dWrPtnVQfWUinPFppNJmA",
  "version": {
    "number": "6.4.2",
    "build_flavor": "default",
    "build_type": "tar",
    "build_hash": "04711c2",
    "build_date": "2018-09-26T13:34:09.098244Z",
    "build_snapshot": false,
    "lucene_version": "7.4.0",
    "minimum_wire_compatibility_version": "5.6.0",
    "minimum_index_compatibility_version": "5.0.0"
  },
  "tagline": "You Know, for Search"
}

jvm: 1.8
plugins: raw docker img from https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html

Description of the problem including expected versus actual behavior:
Different validation rules for WKT vs own format

Steps to reproduce:

  1. Mapping for example with weak requirements (for twitter) from Update ShapeBuilder and GeoPolygonQueryParser to accept non-closed GeoJSON #11161
PUT /example
{
    "mappings": {
        "doc": {
            "properties": {
                "location": {
                    "type": "geo_shape",
                    "tree": "quadtree",
                    "precision": "100m",
                    "coerce": true
                }
            }
        }
    }
}
  1. Coordinates with usual type works perfectly
POST /example/doc
{
    "location" : {
        "type" : "polygon",
        "coordinates" : [
            [ [114.200488, -8.413208], [114.200488, -8.348076], [114.317869, -8.348076], [114.317869, -8.413208] ]
        ]
    }
}
  1. WKT-format procuses error
POST /example/doc
{
    "location" : "Polygon((114.200488 -8.413208, 114.200488 -8.348076, 114.317869 -8.348076, 114.317869 -8.413208))"
}

Output:

{
   "error": {
      "root_cause": [
         {
            "type": "mapper_parsing_exception",
            "reason": "failed to parse [location]"
         }
      ],
      "type": "mapper_parsing_exception",
      "reason": "failed to parse [location]",
      "caused_by": {
         "type": "illegal_argument_exception",
         "reason": "invalid LinearRing found (coordinates are not closed)"
      }
   },
   "status": 400
}

Metadata

Metadata

Assignees

Labels

:Analytics/GeoIndexing, search aggregations of geo points and shapes>bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions