Challenge - 5 Problems
Geo-proximity Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2: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
Attempts:
2 left
💡 Hint
Use the modern GEOSEARCH command with BYRADIUS and WITHDIST to get sorted results.
✗ Incorrect
GEOSEARCH with BYRADIUS and WITHDIST returns members within the radius sorted by distance ascending. GEORADIUS is deprecated and may not guarantee sorting.
🧠 Conceptual
intermediate1:30remaining
Understanding GEOADD and member storage
What does the GEOADD command do in Redis when used with a sorted set?
Attempts:
2 left
💡 Hint
GEOADD stores geographic data as scores in a sorted set.
✗ Incorrect
GEOADD adds members with longitude and latitude, encoding them as geohash scores internally in the sorted set.
📝 Syntax
advanced1: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)?
Attempts:
2 left
💡 Hint
Check the order of options WITHDIST and ASC in the command.
✗ Incorrect
The ASC keyword must come immediately after BYRADIUS and before any WITH* options. Option D places ASC after WITHDIST, causing a syntax error.
❓ optimization
advanced2: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?
Attempts:
2 left
💡 Hint
Think about partitioning data to reduce search space.
✗ Incorrect
Partitioning locations into multiple sorted sets by region reduces the number of items searched, improving query speed.
🔧 Debug
expert3: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?
Attempts:
2 left
💡 Hint
Remember the order of longitude and latitude in GEO commands.
✗ Incorrect
Redis GEO commands expect longitude first, then latitude. Swapping them causes the search to look in the wrong area, returning empty results.