# Geo\_distance query - illegal latitude value that isn't the latitude I sent

**URL:** <https://discuss.elastic.co/t/geo-distance-query-illegal-latitude-value-that-isnt-the-latitude-i-sent/160913>\
**Category:** Elasticsearch\
**Created:** [December 14, 2018, 1:54pm UTC](https://discuss.elastic.co/t/geo-distance-query-illegal-latitude-value-that-isnt-the-latitude-i-sent/160913 "2018-12-14T13:54:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ndtreviv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ndtreviv/32/22494_2.png) [@ndtreviv](https://discuss.elastic.co/u/ndtreviv)\
**Post date:** [December 14, 2018, 1:54pm UTC](https://discuss.elastic.co/t/geo-distance-query-illegal-latitude-value-that-isnt-the-latitude-i-sent/160913/1 "2018-12-14T13:54:45Z")

</div>

I'm getting some odd behaviour when doing geo\_distance queries via the Rest High Level API on elasticsearch v6.2.4.

For example, my query is this:

```auto
{
  "from":0,
  "size":20,
  "query": {
    "bool": {
      "must": [{
        "geo_distance": {
          "location":[34.06388166666667,-118.358675],
          "distance":1.0,
          "distance_type":"arc",
          "validation_method":"STRICT",
          "ignore_unmapped":false,
          "boost":1.0
        }
     }],
     "adjust_pure_negative":true,
     "boost": 1.0
    }
  },
  "explain":false,
  "_source":{"includes":[],"excludes":[]}
}

```

But it responds with this as the `root_cause`:

```auto
"type":"query_parsing_exception",
"reason":"illegal latitude value [264.375] for [geo_distance]"

```

What's happening here? That is not the latitude I queried with, as you can see.

Any help is much appreciated.

**Update** : I also notice that in the query the values are presented as `[lon,lat]` rather than `[lat,lon]`. I'm using the QueryBuilder correctly:

```auto
                    QueryBuilders.geoDistanceQuery(LOCATION_FIELD)
                            .point(lat, lon)
                            .distance(distance, unit)
                            .geoDistance(geoDistance));

```

According to the `point` method in the builder:

```auto
    public GeoDistanceQueryBuilder point(double lat, double lon) {
    ...

```

---

<div class="post-metadata">

**Author:** ![ndtreviv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ndtreviv/32/22494_2.png) [@ndtreviv](https://discuss.elastic.co/u/ndtreviv)\
**Post date:** [December 17, 2018, 3:02pm UTC](https://discuss.elastic.co/t/geo-distance-query-illegal-latitude-value-that-isnt-the-latitude-i-sent/160913/3 "2018-12-17T15:02:11Z")

</div>

Turns out that this was because my proxy node was pointing at an older version of elasticsearch. The error doesn't make much sense, but there you go.

---

<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 14, 2019, 3:02pm UTC](https://discuss.elastic.co/t/geo-distance-query-illegal-latitude-value-that-isnt-the-latitude-i-sent/160913/4 "2019-01-14T15:02:22Z")

</div>

Closed on January 14, 2019, 3:02pm UTC

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