# Geo\_bounds aggregation returns empty data for Multi-Polygon Country Geometries

**URL:** <https://discuss.elastic.co/t/geo-bounds-aggregation-returns-empty-data-for-multi-polygon-country-geometries/311886>\
**Category:** Elasticsearch\
**Created:** [August 10, 2022, 10:55pm UTC](https://discuss.elastic.co/t/geo-bounds-aggregation-returns-empty-data-for-multi-polygon-country-geometries/311886 "2022-08-10T22:55:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![corndog](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/corndog/32/96803_2.png) [@corndog](https://discuss.elastic.co/u/corndog)\
**Post date:** [August 10, 2022, 10:55pm UTC](https://discuss.elastic.co/t/geo-bounds-aggregation-returns-empty-data-for-multi-polygon-country-geometries/311886/1 "2022-08-10T22:55:33Z")

</div>

geo\_bounds aggregation fails to generate geo\_bounds for SOME countries (large countries?) in my dataset, how can I fix this\>?

My example query against a country "New Zealand"

```auto
GET countries/_search
 {
      "query": {
        "bool": {
          "must": [
            {
              "match": {
                "search_name.exact": {
                  "query": "New Zealand",
                  "operator": "and",
                  "fuzziness": 0
                }
              }
            }
          ]
        }
      },
      "aggs": {
        "viewport": {
          "geo_bounds": {
            "field": "geometry",
            "wrap_longitude": true
          }
        }
      }
   } 

```

The results:

```auto
{
  "took" : 21,
  "timed_out" : false,
  "_shards" : {
    "total" : 14,
    "successful" : 14,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 5.1119876,
    "hits" : [
      {
        "_index" : "countries",
        "_type" : "_doc",
        "_id" : "dlCgf4IBGlxVHLiS8Lvb",
        "_score" : 5.1119876,
        "_ignored" : [
          "geometry"
        ],
        "_source" : {
          "id" : 134,
          "search_name" : "New Zealand",
          "iso_cc" : "NU",
          "continent" : "Oceania",
          "countryaff" : "New Zealand",
          "extent_area" : 1.89656638688E14,
          "vertex_count" : 34531.0,
          "geometry" : {
            "type" : "MultiPolygon",
            "coordinates" : [............]
  },
  "aggregations" : {
    "viewport" : { }
  }
}

```

As you can see the "viewport" is empty, and this happens for MOST countries in my dataset, even though they render correctly

---

<div class="post-metadata">

**Author:** ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)\
**Post date:** [August 12, 2022, 5:04am UTC](https://discuss.elastic.co/t/geo-bounds-aggregation-returns-empty-data-for-multi-polygon-country-geometries/311886/2 "2022-08-12T05:04:03Z")

</div>

Hello,

I think the key part of the output you provided is the following:

```auto
"_ignored" : [
    "geometry"
],

```

That is telling me that your mapping has the flag `ignore_malformed` set to true and the actual geometry was considered malformed and ignored. Therefore it is not added to the bounds computation.

You need to find out why the geometry is not being parsed properly which might be because of an issue in the geometry or a bug in Elasticsearch. Which version are you using?

---

<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:** [September 9, 2022, 5:04am UTC](https://discuss.elastic.co/t/geo-bounds-aggregation-returns-empty-data-for-multi-polygon-country-geometries/311886/3 "2022-09-09T05:04:49Z")

</div>

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