# Geo Bounding Box Filter

**URL:** https://discuss.elastic.co/t/geo-bounding-box-filter/102785
**Category:** Elasticsearch
**Created:** [October 5, 2017, 4:56am UTC](https://discuss.elastic.co/t/geo-bounding-box-filter/102785 "2017-10-05T04:56:59Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Atul\_Harsha](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@Atul\_Harsha](https://discuss.elastic.co/u/Atul_Harsha)
#### Post date: [October 5, 2017, 4:56am UTC](https://discuss.elastic.co/t/geo-bounding-box-filter/102785/1 "2017-10-05T04:56:59Z")

</div>

Hi ,  
While trying geo\_bounding\_box following error is generated. Can you please help me out in resolving the error

Code:

```
GET /attractions/restaurant/_search
    {
      "query": {
        "filtered": {
          "filter": {
            "geo_bounding_box": {
              "location": { 
                "top_left": {
                  "lat": 40.8,
                  "lon": -74.0
                },
                "bottom_right": {
                  "lat": 40.7,
                  "lon": -73.0
                }
              }
            }
          }
        }
      }
    }

```

Response :

```
{
      "error": {
        "root_cause": [
          {
            "type": "parsing_exception",
            "reason": "no [query] registered for [filter]",
            "line": 6,
            "col": 21
          }
        ],
        "type": "parsing_exception",
        "reason": "no [query] registered for [filter]",
        "line": 6,
        "col": 21
      },
      "status": 400
    }tered]",
        "line": 3,
        "col": 17
      },
      "status": 400
    }
```

---

<div class="post-metadata">

### Author: ![rockybean](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rockybean/32/11443_2.png) [@rockybean](https://discuss.elastic.co/u/rockybean)
#### Post date: [October 5, 2017, 5:05am UTC](https://discuss.elastic.co/t/geo-bounding-box-filter/102785/2 "2017-10-05T05:05:33Z")

</div>

It should be like this.

```
GET /_search
{
    "query": {
        "bool" : {
            "must" : {
                "match_all" : {}
            },
            "filter" : {
                "geo_bounding_box" : {
                    "pin.location" : {
                        "top_left" : {
                            "lat" : 40.73,
                            "lon" : -74.1
                        },
                        "bottom_right" : {
                            "lat" : 40.01,
                            "lon" : -71.12
                        }
                    }
                }
            }
        }
    }
}
```

---

<div class="post-metadata">

### Author: ![Atul\_Harsha](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@Atul\_Harsha](https://discuss.elastic.co/u/Atul_Harsha)
#### Post date: [October 5, 2017, 5:16am UTC](https://discuss.elastic.co/t/geo-bounding-box-filter/102785/3 "2017-10-05T05:16:34Z")

</div>

> [@rockybean](#):
>
> Hi @rockybean  
> Thanks for your response, but still I am facing some issues can you help me in resolving it?

Still receiving some errors  
Data :

```
PUT /attractions/restaurant/1
{
  "name": "Chipotle Mexican Grill",
  "location": "40.715, -74.011" 
}

PUT /attractions/restaurant/2
{
  "name": "Pala Pizza",
  "location": { 
    "lat": 40.722,
    "lon": -73.989
  }
}

PUT /attractions/restaurant/3
{
  "name": "Mini Munchies Pizza",
  "location": [-73.983, 40.719] 
}

```

Searching :

```
GET /attractions/restaurant/_search
    {
        "query": {
            "bool" : {
                "must" : {
                    "match_all" : {}
                },
                "filter" : {
                    "geo_bounding_box" : {
                        "pin.location" : {
                            "top_left" : {
                                "lat" : 40.73,
                                "lon" : -74.1
                            },
                            "bottom_right" : {
                                "lat" : 40.01,
                                "lon" : -71.12
                            }
                        }
                    }
                }
            }
        }
    }

```

Error :

```
{
  "error": {
    "root_cause": [
      {
        "type": "query_shard_exception",
        "reason": "failed to find geo_point field [pin.location]",
        "index_uuid": "UN1axDBhQUK1hbyEjCq_Rw",
        "index": "attractions"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "attractions",
        "node": "MZOPRP3TTTev18if9HD8qA",
        "reason": {
          "type": "query_shard_exception",
          "reason": "failed to find geo_point field [pin.location]",
          "index_uuid": "UN1axDBhQUK1hbyEjCq_Rw",
          "index": "attractions"
        }
      }
    ]
  },
  "status": 400
}

```

---

<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: [October 5, 2017, 5:30am UTC](https://discuss.elastic.co/t/geo-bounding-box-filter/102785/4 "2017-10-05T05:30:49Z")

</div>

Try with `location` instead as `pin.location` does not exist.

---

<div class="post-metadata">

### Author: ![Atul\_Harsha](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@Atul\_Harsha](https://discuss.elastic.co/u/Atul_Harsha)
#### Post date: [October 5, 2017, 5:36am UTC](https://discuss.elastic.co/t/geo-bounding-box-filter/102785/5 "2017-10-05T05:36:52Z")

</div>

Thank You @dadoonet this works fine 😄 👍

---

<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: [November 2, 2017, 5:37am UTC](https://discuss.elastic.co/t/geo-bounding-box-filter/102785/6 "2017-11-02T05:37:12Z")

</div>

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