# GeoDistance Query Error - ES 5.0

**URL:** <https://discuss.elastic.co/t/geodistance-query-error-es-5-0/66272>\
**Category:** Elasticsearch\
**Created:** [November 16, 2016, 4:56pm UTC](https://discuss.elastic.co/t/geodistance-query-error-es-5-0/66272 "2016-11-16T16:56:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![surbi](https://avatars.discourse-cdn.com/v4/letter/s/e9a140/32.png) [@surbi](https://discuss.elastic.co/u/surbi)\
**Post date:** [November 16, 2016, 4:56pm UTC](https://discuss.elastic.co/t/geodistance-query-error-es-5-0/66272/1 "2016-11-16T16:56:50Z")

</div>

Hi Everyone,

I want to implement proximity search in ES 5.0.0 using Geo-Distance queries. The syntax is the same as specified in the ES 5.0 documentation but still I am getting an error.  
Looking forward to get help on this .....

My Query (testsfdc is my index which stores all customer records with a field location(lat,lon)

```auto
GET /testsfdc/_search
{
  "query": {
      "bool": {
          "must": [
             {"match_all": {}}
          ]
      },
      "filter":{
          "geo_distance": {
             "distance": 10,
             "distance_unit": "km",
             "location": {
                "lat": 50.4724833,
                "lon": 4.8179051
             }
          }
      }
  }  
} 

```

Error -

```auto
{
   "error": {
      "root_cause": [
         {
            "type": "parsing_exception",
            "reason": "[bool] malformed query, unexpected [FIELD_NAME] found [filter]",
            "line": 8,
            "col": 7
         }
      ],
      "type": "parsing_exception",
      "reason": "[bool] malformed query, unexpected [FIELD_NAME] found [filter]",
      "line": 8,
      "col": 7
   },
   "status": 400
}

```

I know the error says syntax before "filter" is wrong but I tried playing around but in vain.

Thanks in advance,  
Surbi

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 16, 2016, 9:26pm UTC](https://discuss.elastic.co/t/geodistance-query-error-es-5-0/66272/2 "2016-11-16T21:26:37Z")

</div>

Please format your code using `</>` icon. It will make your post more readable.  
I updated your question.

`filter` should be inside `bool` and not outside. See [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html)

---

<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:** [December 14, 2016, 9:26pm UTC](https://discuss.elastic.co/t/geodistance-query-error-es-5-0/66272/3 "2016-12-14T21:26:36Z")

</div>

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