Complete the code to add a location with longitude and latitude to a sorted set.
GEOADD locations 13.361389 38.115556 [1]
The GEOADD command adds a location with longitude and latitude to the sorted set named locations. The first arguments after the key are longitude and latitude, followed by the member name, here Sicily.
Complete the code to find locations within 100 km radius from given coordinates.
GEORADIUS locations 15 37 [1] km
The GEORADIUS command finds members within a radius. Here, the radius is 100 kilometers.
Fix the error in the command to get the distance between two locations.
GEODIST locations Sicily [1] kmThe GEODIST command calculates the distance between two members. The member name must match exactly, here Palermo.
Fill both blanks to get locations within 50 km and sort results by distance.
GEORADIUS locations 15 37 [1] km [2]
DESC instead of ASC for sorting.The radius is 50 km, and ASC sorts results from nearest to farthest.
Fill all three blanks to get locations within 100 km, sorted ascending, and include distances in output.
GEORADIUS locations 15 37 [1] km [2] WITHDIST [3]
ASC and DESC.WITHDIST for distances.The radius is 100 km, sorting ascending with ASC, and limiting results to 5 with COUNT 5. The WITHDIST option includes distances in the output.