GEOSEARCH to find the members of a geospatial index that fall inside a circle or a rectangle.
The center is either an existing member of the index (FROMMEMBER) or an explicit coordinate pair (FROMLONLAT). The area is either a circle of a given radius (BYRADIUS) or an axis-aligned box of a given width and height centered on that point (BYBOX), which is the shape to use when you are covering a map viewport rather than a “within N km” question.
By default only member names come back. WITHDIST adds the distance from the center in the unit of the query, WITHCOORD the member’s coordinates, and WITHHASH its raw geohash score. ASC and DESC sort by distance, and COUNT caps the number of results; adding ANY lets the server return as soon as it has enough matches, which is faster but no longer gives you the nearest ones.
GEOSEARCH replaces the deprecated GEORADIUS and GEORADIUSBYMEMBER commands and is the command to use for new code. Use GEOSEARCHSTORE when the result should be stored instead of returned.
Syntax
Arguments
Response
The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.
Examples
TCP examples use the TLSREDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.
Redis CLI
Redis CLI
@upstash/redis
@upstash/redis
upstash_redis
upstash_redis
ioredis
ioredis
node-redis
node-redis
redis-py
redis-py
go-redis
go-redis
jedis
jedis
redis-rs
redis-rs