Can not create a document has mutlipolygon having hole

Hi, can anyone help me
I am facing a following.

Summary
Can not create a document has mutlipolygon having hole.
I do not know why responses reason is correct or this is bug?
I have visualize the multipolygon, using geojson.
But , It seems correct polygon, I mean hole is within polygon.
Another document has polygon having hole is successfuly created.
So I guess specific polygon data can not be created.

Expected behavior
The document is successfuly created.

Actual behavior
Can not create a document.
The reponse is status 400.

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "failed to parse field [location] of type [geo_shape]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "failed to parse field [location] of type [geo_shape]",
    "caused_by": {
      "type": "invalid_shape_exception",
      "reason": "Invalid shape: Hole is not within polygon"
    }
  },
  "status": 400
}

Steps to reproduce the problem

Using kibana devtool, put following requests.

DELETE geo

POST geo/_doc
{}

PUT geo/_mapping
{
  "properties": {
    "location": {
      "type": "geo_shape"
    }
  }
}

POST /geo/_doc
{
  "location": {
    "type": "multipolygon",
    "coordinates": [
      [
        [
          [
            136.213733593,
            35.786550021
          ],
          [
            136.213891619,
            35.786492823
          ],
          [
            136.214369639,
            35.786314141
          ],
          [
            136.214423308,
            35.786327978
          ],
          [
            136.214762481,
            35.787228399
          ],
          [
            136.214867863,
            35.78749709
          ],
          [
            136.214150004,
            35.787679904
          ],
          [
            136.213733593,
            35.786550021
          ]
        ],
        [
          [
            136.213703006,
            35.786561093
          ],
          [
            136.212561159,
            35.788209032
          ],
          [
            136.214047375,
            35.787822628
          ],
          [
            136.215960152,
            35.787316346
          ],
          [
            136.215922928,
            35.78721168
          ],
          [
            136.215682347,
            35.787289767
          ],
          [
            136.214932678,
            35.787475211
          ],
          [
            136.214644095,
            35.786154679
          ],
          [
            136.2133956,
            35.78660853
          ],
          [
            136.213703006,
            35.786561093
          ]
        ]
      ]
    ]
  }
}

Environment
ES 7.1.1

Your data is not valid GeoJSON - you should put the outline of the shape first and then list any holes, but instead you have put the hole first and the outline second, hence the message about the hole not being within the outline. If you switch them over then it should work:


    "coordinates": [
      [
        [
          [
            136.213703006,
            35.786561093
          ],
          [
            136.212561159,
            35.788209032
          ],
          [
            136.214047375,
            35.787822628
          ],
          [
            136.215960152,
            35.787316346
          ],
          [
            136.215922928,
            35.78721168
          ],
          [
            136.215682347,
            35.787289767
          ],
          [
            136.214932678,
            35.787475211
          ],
          [
            136.214644095,
            35.786154679
          ],
          [
            136.2133956,
            35.78660853
          ],
          [
            136.213703006,
            35.786561093
          ]
        ],
        [
          [
            136.213733593,
            35.786550021
          ],
          [
            136.213891619,
            35.786492823
          ],
          [
            136.214369639,
            35.786314141
          ],
          [
            136.214423308,
            35.786327978
          ],
          [
            136.214762481,
            35.787228399
          ],
          [
            136.214867863,
            35.78749709
          ],
          [
            136.214150004,
            35.787679904
          ],
          [
            136.213733593,
            35.786550021
          ]
        ]
      ]
    ]
1 Like

Thank you so much for your quick reply.
I have understood the reason why. The data is invalid GeoJSON.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.