Distance in meters when using within_geo_range

How do I have the query return how far away the object is from the supplied GeoCoordinate?

I cannot seem to get that data from the response.

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.DataType.GEO_COORDINATES)
    ]
)
collection.data.insert_many(
    objects=[
        {"city_name": "Belo Horizonte", "geo": {"latitude": -19.9191, "longitude": -43.9387}},
        {"city_name": "Amsterdam", "geo": {"latitude": 52.377956, "longitude": 4.897070}},
        {"city_name": "São Paulo", "geo": {"latitude": -23.5558, "longitude": -46.6396}},
        {"city_name": "Tokyo", "geo": {"latitude": 35.6764, "longitude": 139.6500}},
        {"city_name": "New York", "geo": {"latitude": 40.7128, "longitude": -74.0060}},
        {"city_name": "Paris", "geo": {"latitude": 48.8566, "longitude": 2.3522}},
        {"city_name": "Sydney", "geo": {"latitude": -33.8688, "longitude": 151.2093}},
        {"city_name": "Cape Town", "geo": {"latitude": -33.9249, "longitude": 18.4241}},
        {"city_name": "Mumbai", "geo": {"latitude": 19.0760, "longitude": 72.8777}},
        {"city_name": "Moscow", "geo": {"latitude": 55.7558, "longitude": 37.6176}}
    ]
)
query = collection.query.fetch_objects(
    return_metadata=wvc.query.MetadataQuery(distance=True),
    filters=(
        wvc.query.Filter.by_property("geo").within_geo_range(
            wvc.data.GeoCoordinate(
                latitude=-17.8575,
                longitude=-41.5057,
            ),
            distance=1000000
        )
    )
)
for i in query.objects:
    print("#"*10)
    print(i.properties)
    print(i.metadata)

the output, as expected:

##########
{‘geo’: GeoCoordinate(latitude=-23.55579948425293, longitude=-46.63959884643555), ‘city_name’: ‘São Paulo’}
MetadataReturn(creation_time=None, last_update_time=None, distance=None, certainty=None, score=None, explain_score=None, is_consistent=None, rerank_score=None)
##########
{‘city_name’: ‘Belo Horizonte’, ‘geo’: GeoCoordinate(latitude=-19.919099807739258, longitude=-43.93870162963867)}
MetadataReturn(creation_time=None, last_update_time=None, distance=None, certainty=None, score=None, explain_score=None, is_consistent=None, rerank_score=None)

So having something like, could be helpful:

return_metadata=wvc.query.MetadataQuery(geo_distance=True),