# Can not create a document has mutlipolygon having hole

**URL:** https://discuss.elastic.co/t/can-not-create-a-document-has-mutlipolygon-having-hole/212160
**Category:** Elasticsearch
**Created:** [December 17, 2019, 12:24pm UTC](https://discuss.elastic.co/t/can-not-create-a-document-has-mutlipolygon-having-hole/212160 "2019-12-17T12:24:08Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![whiteonyx\_go](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whiteonyx_go/32/59541_2.png) [@whiteonyx\_go](https://discuss.elastic.co/u/whiteonyx_go)
#### Post date: [December 17, 2019, 12:24pm UTC](https://discuss.elastic.co/t/can-not-create-a-document-has-mutlipolygon-having-hole/212160/1 "2019-12-17T12:24:08Z")

</div>

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.

 ![スクリーンショット 2019-12-17 20.44.50](https://us1.discourse-cdn.com/elastic/original/3X/3/9/39a4e4bbf8f57f2a6d2f3d6894b12b88d13c7b50.png)

**Expected behavior**  
The document is successfuly created.

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

```auto
{
  "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.

```auto
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

---

<div class="post-metadata">

### Author: ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)
#### Post date: [December 17, 2019, 12:40pm UTC](https://discuss.elastic.co/t/can-not-create-a-document-has-mutlipolygon-having-hole/212160/2 "2019-12-17T12:40:11Z")

</div>

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:

```auto

    "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
          ]
        ]
      ]
    ]

```

---

<div class="post-metadata">

### Author: ![whiteonyx\_go](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whiteonyx_go/32/59541_2.png) [@whiteonyx\_go](https://discuss.elastic.co/u/whiteonyx_go)
#### Post date: [December 18, 2019, 1:19pm UTC](https://discuss.elastic.co/t/can-not-create-a-document-has-mutlipolygon-having-hole/212160/3 "2019-12-18T13:19:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [January 15, 2020, 1:28pm UTC](https://discuss.elastic.co/t/can-not-create-a-document-has-mutlipolygon-having-hole/212160/4 "2020-01-15T13:28:23Z")

</div>

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