# Geo Distance Query and OR Syntax?

**URL:** <https://discuss.elastic.co/t/geo-distance-query-and-or-syntax/226282>\
**Category:** Elasticsearch\
**Created:** [April 2, 2020, 8:37pm UTC](https://discuss.elastic.co/t/geo-distance-query-and-or-syntax/226282 "2020-04-02T20:37:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![west415](https://avatars.discourse-cdn.com/v4/letter/w/919ad9/32.png) [@west415](https://discuss.elastic.co/u/west415)\
**Post date:** [April 2, 2020, 8:37pm UTC](https://discuss.elastic.co/t/geo-distance-query-and-or-syntax/226282/1 "2020-04-02T20:37:33Z")

</div>

I am using Elasticsearch 7.6 and trying to run a query that runs a geo\_distance query to find matching documents within an exact city **OR** within a distance range of 25 miles in this case.

In layman's terms, it would be "Do a search for all jobs in the city of "Santa Rosa, CA" OR 25 miles around it. If there are jobs within 25 miles of Santa Rosa, CA those documents should be returned in the search results as well as any matches where the "job\_location" is specifically "Santa Rosa, CA" if that makes sense.

Here is my query, which returns 0 results despite there being matching documents within 25 miles of my specified longitude and latitude which is Santa Rosa, CA.

I must have the syntax wrong.

```auto
{
  "query": {
    "bool": {
      "filter": {
        "geo_distance": {
          "distance": "25 miles",
          "geo_location": "38.440429,-122.7140548"
        }
      },
      "must": [
        {
          "match": {
            "active": true
          }
        },
        {
          "bool": {
            "should": [
              {
                "term": {
                  "job_location": "Santa Rosa, CA"
                }
              }
            ]
          }
        }
      ]
    }
  }
}
```

---

<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:** [April 30, 2020, 8:37pm UTC](https://discuss.elastic.co/t/geo-distance-query-and-or-syntax/226282/2 "2020-04-30T20:37:33Z")

</div>

Closed on April 30, 2020, 8:37pm UTC

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