# 1.7 to 5.3 Migration: Range filtering on geo\_points not working on v5.3

**URL:** <https://discuss.elastic.co/t/1-7-to-5-3-migration-range-filtering-on-geo-points-not-working-on-v5-3/189273>\
**Category:** Elasticsearch\
**Created:** [July 8, 2019, 2:13am UTC](https://discuss.elastic.co/t/1-7-to-5-3-migration-range-filtering-on-geo-points-not-working-on-v5-3/189273 "2019-07-08T02:13:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![zheryu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zheryu/32/49621_2.png) [@zheryu](https://discuss.elastic.co/u/zheryu)\
**Post date:** [July 8, 2019, 2:13am UTC](https://discuss.elastic.co/t/1-7-to-5-3-migration-range-filtering-on-geo-points-not-working-on-v5-3/189273/1 "2019-07-08T02:13:24Z")

</div>

Hi friends,

I'm migrating my Elasticsearch from 1.7 to 5.3, and have noticed inconsistencies in how range filters interact with geo\_point data types. My query to 1.7 returns data successfully, while my query to 5.3 gives me nothing.

My search query to 1.7 (some fields redacted for company reasons) looks something like:

```
{
  "query": {
    "filtered": {
      "filter": {
        "and": {
          "filters": [
            {
              "bool": {
                "must": [
                  {
                    "and": {
                      "filters": [
                        {
                          "range": {
                            "x.y.z.lon": {
                              "from": null,
                              "to": -74.97070312500001,
                              "include_lower": true,
                              "include_upper": false
                            },
                            "_cache": false
                          }
                        }
                      ]
                    }
                  }
                ],
                "_cache": true
              }
            }
          ],
          "_cache": false
        }
      }
    }
  }
}

```

My query to 5.3 looks something like this:

```
{
  "from": 0,
  "size": 0,
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "filter": [
              {
                "range": {
                  "x.y.z.lon": {
                    "gt": null,
                    "lt": "-74.97070312500001"
                  }
                }
              }
            ]
          }
        }
      ]
    }
  }
}

```

Here are my mappings for the relevant fields (extra fields trimmed out):

v1.7:

```
"my_17_mapping": {
    "_routing": {
      "required": true
    },
    "dynamic": "true",
    "dynamic_templates": [
      {
        "strings_template": {
          "mapping": {
            "norms": {
              "enabled": false
            },
            "index": "not_analyzed",
            "type": "string",
            "doc_values": true
          },
          "match_mapping_type": "string",
          "match": "*"
        }
      },
      {
        "dynamic_default": {
          "mapping": {
            "norms": {
              "enabled": false
            },
            "doc_values": true
          },
          "match_mapping_type": "*",
          "match": "*"
        }
      }
    ],
    "date_detection": false,
    "properties": {
      "x": {
        "properties": {
          "y": {
            "properties": {
              "z": {
                "type": "geo_point",
                "lat_lon": true,
                "doc_values": true
              }
            }
          }
        }
      }
    }
  }
}

```

v5.3:

```
{
  "my_53_index": {
    "mappings": {
      "my_53_mapping": {
        "dynamic": "true",
        "_routing": {
          "required": true
        },
        "dynamic_templates": [
          {
            "strings_template": {
              "match": "*",
              "match_mapping_type": "string",
              "mapping": {
                "doc_values": true,
                "norms": false,
                "type": "keyword"
              }
            }
          },
          {
            "dynamic_default": {
              "match": "*",
              "mapping": {
                "doc_values": true,
                "norms": false
              }
            }
          }
        ],
        "date_detection": false,
        "numeric_detection": false,
        "properties": {
          "x": {
            "properties": {
              "y": {
                "properties": {
                  "z": {
                    "type": "geo_point"
                  },
                }
              }
            }
          }
        }
      }
    }
  }
}

```

Could anyone help me understand why these queries aren't returning the same thing? Perhaps a breaking change between the two versions or a problem with my mappings?

---

<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:** [July 8, 2019, 1:11pm UTC](https://discuss.elastic.co/t/1-7-to-5-3-migration-range-filtering-on-geo-points-not-working-on-v5-3/189273/2 "2019-07-08T13:11:43Z")

</div>

Hi,

I have no much experience with 1.7 but `geo_point` field uses a totally different structure in 5.3 and I think you cannot use range queries to filter them. Have a look to the documentation:

[https://www.elastic.co/guide/en/elasticsearch/reference/5.3/geo-point.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/geo-point.html)

I think you need to use a `geo_boundig_box` for what you are trying to do, something like:

```auto
{
  "from": 0,
  "size": 0,
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "filter": [
              {
                "geo_bounding_box": {
                  "x.y.z.lon": {
                   "top_left" : {
                            "lat" : 90,
                            "lon" : -180
                        },
                        "bottom_right" : {
                            "lat" : -90,
                            "lon" : -74.97070312500001
                        }
                  }
                }
              }
            ]
          }
        }
      ]
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![zheryu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zheryu/32/49621_2.png) [@zheryu](https://discuss.elastic.co/u/zheryu)\
**Post date:** [July 8, 2019, 7:43pm UTC](https://discuss.elastic.co/t/1-7-to-5-3-migration-range-filtering-on-geo-points-not-working-on-v5-3/189273/3 "2019-07-08T19:43:18Z")

</div>

Interesting, thanks!

Just one followup question. If geo\_point fields do not support range filtering, how come no exceptions are thrown to let me know that this query is invalid?

---

<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:** [July 9, 2019, 9:08am UTC](https://discuss.elastic.co/t/1-7-to-5-3-migration-range-filtering-on-geo-points-not-working-on-v5-3/189273/4 "2019-07-09T09:08:15Z")

</div>

Not sure why you are not getting an exception. In newer versions of Elasticsearch it does throw an error if you try to run a range query over a geo\_point field:

```auto
"caused_by": {
            "type": "illegal_argument_exception",
            "reason": "Field [location] of type [geo_point] does not support range queries"
          }

```

Maybe an issue on the version you are working on but I have not tried it.

---

<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:** [July 10, 2019, 2:56pm UTC](https://discuss.elastic.co/t/1-7-to-5-3-migration-range-filtering-on-geo-points-not-working-on-v5-3/189273/5 "2019-07-10T14:56:53Z")

</div>

I revisited this issue and I understand why you do not get an error. The field you are using in the range aggregation is 'x.y.z.lon' which it does not exist in the new version. This is not an error in Elasticsearch, if you change the field to `x.y.z' then you will get the error above.

---

<div class="post-metadata">

**Author:** ![zheryu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zheryu/32/49621_2.png) [@zheryu](https://discuss.elastic.co/u/zheryu)\
**Post date:** [July 10, 2019, 5:55pm UTC](https://discuss.elastic.co/t/1-7-to-5-3-migration-range-filtering-on-geo-points-not-working-on-v5-3/189273/6 "2019-07-10T17:55:43Z")

</div>

Gotcha, thanks!

---

<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:** [August 7, 2019, 5:55pm UTC](https://discuss.elastic.co/t/1-7-to-5-3-migration-range-filtering-on-geo-points-not-working-on-v5-3/189273/7 "2019-08-07T17:55:50Z")

</div>

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