0
0
Redisquery~20 mins

Geo-proximity with sorted sets in Redis - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Geo-proximity Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Find nearby locations within 5 km
Given a Redis sorted set storing locations with their longitude and latitude, which command returns all locations within 5 kilometers of the point (13.361389, 38.115556) sorted by distance?
Redis
GEOADD Sicily 13.361389 38.115556 Palermo 15.087269 37.502669 Catania
GEOSEARCH Sicily FROMLONLAT 13.361389 38.115556 BYRADIUS 5 km ASC WITHDIST
AGEOSEARCH Sicily FROMLONLAT 13.361389 38.115556 BYRADIUS 5 km
BGEORADIUS Sicily 13.361389 38.115556 5 km WITHDIST ASC
CGEOSEARCH Sicily FROMLONLAT 13.361389 38.115556 BYRADIUS 5 km ASC WITHDIST
DGEORADIUS Sicily 13.361389 38.115556 5 km
Attempts:
2 left
💡 Hint
Use the modern GEOSEARCH command with BYRADIUS and WITHDIST to get sorted results.
🧠 Conceptual
intermediate
1:30remaining
Understanding GEOADD and member storage
What does the GEOADD command do in Redis when used with a sorted set?
AAdds a member with longitude and latitude coordinates to a sorted set, using the geohash score internally.
BAdds a member with a numeric score to a sorted set without any coordinate information.
CRemoves a member from a sorted set based on its longitude and latitude.
DReturns the distance between two members in a sorted set.
Attempts:
2 left
💡 Hint
GEOADD stores geographic data as scores in a sorted set.
📝 Syntax
advanced
1:30remaining
Identify the syntax error in GEOSEARCH usage
Which option contains a syntax error when trying to find locations within 10 km of (15, 37)?
AGEOSEARCH Sicily FROMLONLAT 15 37 BYRADIUS 10 km WITHCOORD
BGEOSEARCH Sicily FROMLONLAT 15 37 BYRADIUS 10 km WITHDIST
CGEOSEARCH Sicily FROMLONLAT 15 37 BYRADIUS 10 km ASC WITHDIST
DGEOSEARCH Sicily FROMLONLAT 15 37 BYRADIUS 10 km WITHDIST ASC
Attempts:
2 left
💡 Hint
Check the order of options WITHDIST and ASC in the command.
optimization
advanced
2:30remaining
Optimizing geo queries for large datasets
You have a Redis sorted set with 1 million geo locations. Which approach optimizes querying locations within 1 km radius efficiently?
AUse GEOSEARCH with BYRADIUS 1 km and LIMIT 100 to reduce returned results.
BStore locations in multiple sorted sets by region and query only relevant sets.
CUse GEORADIUS with a large radius and filter results client-side.
DUse GEOADD with higher precision coordinates to improve query speed.
Attempts:
2 left
💡 Hint
Think about partitioning data to reduce search space.
🔧 Debug
expert
3:00remaining
Debugging unexpected empty results from GEOSEARCH
You run the command: GEOSEARCH places FROMLONLAT 40.7128 -74.0060 BYRADIUS 10 km WITHDIST But it returns an empty list, even though you know members exist nearby. What is the most likely cause?
AThe longitude and latitude values are swapped; longitude should be -74.0060 and latitude 40.7128.
BBYRADIUS requires the radius unit to be specified as 'meters' instead of 'km'.
CThe sorted set 'places' does not contain any members added with GEOADD.
DWITHDIST option is not supported with GEOSEARCH and causes no results.
Attempts:
2 left
💡 Hint
Remember the order of longitude and latitude in GEO commands.