# Geosearch WithinGeoRange maxdistance metric not accurate

**URL:** https://forum.weaviate.io/t/geosearch-withingeorange-maxdistance-metric-not-accurate/7707
**Category:** Support
**Tags:** python
**Created:** [November 19, 2024, 5:58pm UTC](https://forum.weaviate.io/t/geosearch-withingeorange-maxdistance-metric-not-accurate/7707 "2024-11-19T17:58:11Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mugndhn](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/mugndhn/32/2617_2.png) [@mugndhn](https://forum.weaviate.io/u/mugndhn)
#### Post date: [November 19, 2024, 5:58pm UTC](https://forum.weaviate.io/t/geosearch-withingeorange-maxdistance-metric-not-accurate/7707/1 "2024-11-19T17:58:11Z")

</div>

### Description

Hello,

I’m having an issue with the `WithinGeoRange` operator for geospatial queries in my database.

Here is the query structure I’m using:

```auto
{
    'operator': 'WithinGeoRange',
    'valueGeoRange': {
        'geoCoordinates': {
            'latitude': coordinates["latitude"],
            'longitude': coordinates["longitude"],
        },
        'distance': {'max': int(distance)}
    },
    'path': ['coordinates']
}

```

Here is a sample document in my database:

```auto
{
    "properties": {
        "coordinates": {
            "latitude": 27.160555,
            "longitude": 78.054596
        },
        "productId": "66ea"
    }
}

```

When I query using the same latitude and longitude as the document (`latitude: 27.160555`, `longitude: 78.054596`) and set the `max` distance to `1000`, I don’t get any results.

**What I’ve Tried:**

1. Verified that the coordinates in the query match the document.
2. Confirmed that the distance is correctly calculated in meters.
3. Checked for typos in the `path` parameter.

Still, the query doesn’t return the document even though it should fall within the range.

**Questions:**

1. Does the `WithinGeoRange` operator support this type of query, or am I missing something in the implementation?
2. Is there a specific distance metric or projection setting I need to configure?
3. Could this be related to a bug, or am I misinterpreting how the geospatial query works?

Any help or pointers would be greatly appreciated!

### Server Setup Information

- Weaviate Server Version:
- Deployment Method: Local docker image ([http://cr.weaviate.io/semitechnologies/weaviate:1.27.2](http://cr.weaviate.io/semitechnologies/weaviate:1.27.2))
- Multi Node? Number of Running Nodes:
- Client Language and Version: Python Client 3.24.1
- Multitenancy?:

---

<div class="post-metadata">

### Author: ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)
#### Post date: [November 20, 2024, 7:04pm UTC](https://forum.weaviate.io/t/geosearch-withingeorange-maxdistance-metric-not-accurate/7707/2 "2024-11-20T19:04:22Z")

</div>

hi @mugndhn !!

Welcome to our community 🤗 !!

Can you reproduce this scenario in a python code?

Here is one that we can use as reference:

> [@Distance in meters when using within\_geo\_range](https://forum.weaviate.io/t/distance-in-meters-when-using-within-geo-range/7531/2):
>
> hi @jensenbox !! That’s interesting. I don’t believe it does thinking I will poke internally about it and keep you posted. I have crafted a small test code for future reference: client.collections.delete("Test") collection = client.collections.create( "Test", vectorizer\_config=wvc.config.Configure.Vectorizer.none(), properties=[ wvc.config.Property(name="city\_name", data\_type=wvc.config.DataType.TEXT), wvc.config.Property(name="geo", data\_type=wvc.config.DataTyp…

This helps us understand exactly what is the code you are using, with some fictional dataset, etc.

LEt me know if this helps!

Thanks!

---

<div class="post-metadata">

### Author: ![mugndhn](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/mugndhn/32/2617_2.png) [@mugndhn](https://forum.weaviate.io/u/mugndhn)
#### Post date: [November 20, 2024, 11:47pm UTC](https://forum.weaviate.io/t/geosearch-withingeorange-maxdistance-metric-not-accurate/7707/3 "2024-11-20T23:47:41Z")

</div>

hi @DudaNogueira,

While I was putting together the notebook for you, I noticed a typo in the query which was swapping lat and long. We were able to fix it and the geosearch seems to be working now.

Thank you.

---

<div class="post-metadata">

### Author: ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)
#### Post date: [November 21, 2024, 5:34pm UTC](https://forum.weaviate.io/t/geosearch-withingeorange-maxdistance-metric-not-accurate/7707/4 "2024-11-21T17:34:32Z")

</div>

Oh!!

Glad to hear you were able to solve this.

Thanks for sharing!!
