Get distance value on radius based geospatial query

Hi everyone,

I’m using couchbase server EE 7.6 and I have a scenario where I need to get documents based on a distance from a certain point (Geopoint distance query) and show that list to the user WITH the distances.

I’ve managed to do the query but I cannot find anywhere in the documentation how to retrieve the actual distance… I mean, if couchbase is sorting it based on the distance it must have that value somewhere, right? How do I retrieve it?

The only articles I’ve found were using haversine formula themselves to do it.

Thank you in advance.

hits.sort has info it might be encoded. cc @abhinav

@mateus.d Unfortunately this sort value of geo distance is encoded and is not meant to be interpreted - the sort key that @vsr1 mentions.

@vsr1 @abhinav I see, I’m guessing there’s no way do decode that info then… I’ll calculate that distance myself . It is weird though that is not available.

Thank you for answering it quickly :smile:

If anyone visits this question in the future there is an article on how to calculate those distances using UDF