Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

GEODIST

Last updated
GEODIST key member1 member2 [M | KM | FT | MI]
Group
Geospatial
Complexity
O(1)
Arity
-4 (at least 4 words, counting the command name)
Flags
read-only
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

GEODIST returns the distance between two members of the geospatial index at key, measured along the Earth’s surface (the Earth is treated as a sphere, so expect an error of up to about 0.5%).

Unit Meaning
M Meters (the default).
KM Kilometers.
FT Feet.
MI Miles.

Units are case-insensitive.

Case RESP2 RESP3
Both members exist Bulk string: the distance with 4 decimals Bulk string
A member or the key is missing Nil bulk string Null

Error replies: ERR unsupported unit provided. please use M, KM, FT, MI, and WRONGTYPE if the key is not a sorted set.

127.0.0.1:6379> GEOADD cities -0.1276 51.5072 london 2.3522 48.8566 paris
(integer) 2
127.0.0.1:6379> GEODIST cities london paris
"343626.8434"
127.0.0.1:6379> GEODIST cities london paris km
"343.6268"
127.0.0.1:6379> GEODIST cities london atlantis
(nil)

Same as Redis 7 and Valkey 8, including the Earth radius used, so distances match.

GEOADD, GEOPOS, GEOSEARCH