# Using geo\_bounding\_box under a should query

**URL:** <https://discuss.elastic.co/t/using-geo-bounding-box-under-a-should-query/156482>\
**Category:** Elasticsearch\
**Created:** [November 13, 2018, 1:44pm UTC](https://discuss.elastic.co/t/using-geo-bounding-box-under-a-should-query/156482 "2018-11-13T13:44:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zivari](https://avatars.discourse-cdn.com/v4/letter/z/9e8a1a/32.png) [@zivari](https://discuss.elastic.co/u/zivari)\
**Post date:** [November 13, 2018, 1:44pm UTC](https://discuss.elastic.co/t/using-geo-bounding-box-under-a-should-query/156482/1 "2018-11-13T13:44:46Z")

</div>

Hey,

What i am Ultimately trying to achieve is, checking if a document location cords is within any of 2 different geo bounding boxes.

In the Documentation i can see a usage example of geo\_bounding\_box under a **filter** query,  
which works fine.  
But, I have been trying to use geo\_bounding\_box under a **should** query with no success. see error below.

The only thing i changed from the example is wrote **should** instead of **filter**  
from my past experience with elastic this works fine with any other type of query (terms, term, range etc)  
but it seems geo\_bounding\_Box is acting different

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

```

}

im getting #\<NoMethodError: undefined method 'geo\_bounding\_box' for  
#Elasticsearch::DSL::Search::Query:0x007f8c54630f78\>;

Why is that? isn't it possible to use geo queries under a should statement?  
if not how can i achieve my goal?

Will appreciate any help,  
Thanks!

---

<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:** [November 14, 2018, 9:46am UTC](https://discuss.elastic.co/t/using-geo-bounding-box-under-a-should-query/156482/2 "2018-11-14T09:46:37Z")

</div>

Hi,

I have tried to reproduce locally your issue and I couldn't. Which version of Elasticsearch are you running on?

---

<div class="post-metadata">

**Author:** ![zivari](https://avatars.discourse-cdn.com/v4/letter/z/9e8a1a/32.png) [@zivari](https://discuss.elastic.co/u/zivari)\
**Post date:** [November 14, 2018, 2:50pm UTC](https://discuss.elastic.co/t/using-geo-bounding-box-under-a-should-query/156482/3 "2018-11-14T14:50:04Z")

</div>

Thanks for the answer.  
actually this is working.

The query i had trouble composing is one that checked if a document falls within 1 of 2 geo bounding boxes. having trouble understanding what i need to do

---

<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 12, 2018, 3:03pm UTC](https://discuss.elastic.co/t/using-geo-bounding-box-under-a-should-query/156482/4 "2018-12-12T15:03:29Z")

</div>

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