GEORADIUSBYMEMBER
Deprecated
As of Redis version 6.2.0, this command is regarded as deprecated.
It can be replaced by GEOSEARCH and GEOSEARCHSTORE with the BYRADIUS and FROMMEMBER arguments when migrating or writing new code.
GEORADIUSBYMEMBER key member radius <M | KM | FT | MI> [WITHCOORD] [WITHDIST] [WITHHASH] [COUNT count [ANY]] [ASC | DESC] [STORE key | STOREDIST key]
- Available since:
- Redis Open Source 3.2.0
- Time complexity:
- O(N+log(M)) where N is the number of elements inside the bounding box of the circular area delimited by center and radius and M is the number of items inside the index.
- ACL categories:
-
@write,@geo,@slow, - Compatibility:
- Redis Software and Redis Cloud compatibility
This command is exactly like GEORADIUS with the sole difference that instead
of taking, as the center of the area to query, a longitude and latitude value, it takes the name of a member already existing inside the geospatial index represented by the sorted set.
The position of the specified member is used as the center of the query.
Please check the example below and the GEORADIUS documentation for more information about the command and its options.
Note that GEORADIUSBYMEMBER_RO is also available since Redis 3.2.10 and Redis 4.0.0 in order to provide a read-only command that can be used in replicas. See the GEORADIUS page for more information.
Required arguments
key
The name of the key that holds the geospatial index (a sorted set).
member
The member whose position is used as the center of the search.
radius
The radius of the search circle, in the unit given by the following argument.
M | KM | FT | MI
The unit for radius: meters (M), kilometers (KM), feet (FT), or miles (MI).
Optional arguments
WITHCOORD
Also return the longitude and latitude of each matching item.
WITHDIST
Also return the distance of each matching item from the center, in the same unit as the radius.
WITHHASH
Also return the raw 52-bit geohash-encoded score of each matching item.
COUNT count [ANY]
Return at most count matches. With ANY, the command returns as soon as enough matches are found — faster, but the results may be unsorted.
ASC | DESC
Sort the results by distance from the center: nearest first (ASC) or farthest first (DESC).
STORE key
Store the results as a geospatial index in key instead of returning them. STORE and STOREDIST are mutually exclusive.
STOREDIST key
Store the results in key as a sorted set of distances from the center, instead of returning them.
Examples
Redis Software and Redis Cloud compatibility
| Redis Software |
Redis Cloud |
Notes |
|---|---|---|
| ✅ Standard |
✅ Standard |
Deprecated as of Redis v6.2.0. |
Return information
One of the following:
- If no
WITH*option is specified, an Array reply of matched member names - If
WITHCOORD,WITHDIST, orWITHHASHoptions are specified, the command returns an Array reply of arrays, where each sub-array represents a single item:- The distance from the center as a floating point number, in the same unit specified in the radius.
- The Geohash integer.
- The coordinates as a two items x,y array (longitude,latitude).
History
- Starting with Redis version 6.2.0: Added the
ANYoption forCOUNT. - Starting with Redis version 7.0.0: Added support for uppercase unit names.