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:
PUT /example
{
"mappings": {
"doc": {
"properties": {
"location": {
"type": "geo_shape",
"tree": "quadtree",
"precision": "100m",
"coerce": true
}
}
}
}
}
POST /example/doc
{
"location" : {
"type" : "polygon",
"coordinates" : [
[ [114.200488, -8.413208], [114.200488, -8.348076], [114.317869, -8.348076], [114.317869, -8.413208] ]
]
}
}
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
}
Pinging @elastic/es-search-aggs
Description of the problem including expected versus actual behavior:
Different validation rules for WKT vs own format
Indeed, the WKT parser ignores the coerce parameter. When a polygon is represented as GeoJSON and it is not closed, we will close it by copying the first coordinate if coerce is set to true. This logic doesn't exist in the WKT parser.
@nknize what do you think? Should we make WKT parser more forgiving if coerce is set to true or should we treat this as a documentation issue?
I think this was an oversight on my part. The spec does require WKT polygons to be closed but coerce was intended to correct those kinds of "simple" issues. So I think we should go ahead and implement coerce support for WKT as well.
Fixed by #35414
@nknize @imotov I don't see the coerce property mentioned in the mapping options for 6.6+: https://www.elastic.co/guide/en/elasticsearch/reference/6.6/geo-shape.html. Should it be added to the docs?
@russcam Thanks for pointing this out. I opened #43340 to fix that .