Geo_bounds aggregation returns empty data for Multi-Polygon Country Geometries

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"

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:

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

Hello,

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

"_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?

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